Wing Commander II
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
smart.c
Go to the documentation of this file.
1/*
2 * Pilot steering, formation flying and maneuver selection.
3 *
4 * Retail object 0x41E4E0-0x42033F (link order; see docs/ORDER.md).
5 */
6#include "game.h"
7
8signed char g_aDefenseManeuversNovice[8] = {
9 24, 24, 13, 14, -1, 0, 0, 0
10}; /* 0x00492fd8 */
12 8, 13, 15, 14, 19, 24, -1, 0
13}; /* 0x00492fe0 */
14signed char g_aDefenseManeuversElite[16] = {
15 8, 15, 17, 23, 19, 9, 20, 24, 14, -1, 0, 0, 0, 0, 0, 0
16}; /* 0x00492fe8 */
17signed char g_aDefenseManeuversAce[16] = {
18 17, 23, 15, 19, 9, 14, 20, 12, -1, 0, 0, 0, 0, 0, 0, 0
19}; /* 0x00492ff8 */
20signed char g_aDefenseManeuversBoss[16] = {
21 15, 19, 12, 11, 17, 23, 7, 9, -1, 0, 0, 0, 0, 0, 0, 0
22}; /* 0x00493008 */
30signed char g_acPilotAggression[8] = {
31 3, 3, 3, 2, 2, 3, 0, 0
32}; /* 0x00493030 */
33signed char g_acPilotRecovery[8] = {
34 6, 7, 8, 8, 9, 8, 0, 0
35}; /* 0x00493038 */
36short g_bWingmanTurnRateUnlocked = 0; /* 0x00493040 */
37
38#pragma function(labs)
39/* Function start: 0x41E4E0 */
40void steer_away_from_object(short obj, short other, short amount)
41{
42 FixedVector predicted;
43 FixedVector gap;
44 FixedVector relative;
45
46 g_anRollGoal[obj] = 0;
48 &g_aShipVelocity[other], &predicted);
50 &predicted, &gap);
51 transform_to_objects_frame(&gap, &relative, obj);
52 if (labs(relative.x) < labs(relative.y)) {
53 if (relative.x > 0)
54 amount = -amount;
55 g_anYawGoal[obj] = amount;
56 } else {
57 if (relative.y > 0)
58 amount = -amount;
59 g_anPitchGoal[obj] = amount;
60 }
61}
62
63void transform_to_objects_frame(const FixedVector *source, FixedVector *destination, short obj);
65void try2end_collision_alert(short obj);
66
67unsigned int offset_location(short obj, const ShortVector *offset, FixedVector *location);
68unsigned int compute_formation_destination(short leader, const ShortVector *offset, FixedVector *destination);
69unsigned int select_target(short obj);
70
71/* Function start: 0x41E5C8 */
72void steer_away_from_predicted_object(short obj, short other,
73 short predictionTicks, short amount)
74{
75 FixedVector predicted;
76 FixedVector delta;
77 FixedVector relative;
78
79 g_anRollGoal[obj] = 0;
81 (int)predictionTicks << 8, &predicted);
83 &predicted, &predicted);
85 &predicted, &delta);
86 transform_to_objects_frame(&delta, &relative, obj);
87 if (labs(relative.x) < labs(relative.y)) {
88 if (relative.x < 0)
89 amount = -amount;
90 g_anYawGoal[obj] = amount;
91 } else {
92 if (relative.y > 0)
93 amount = -amount;
94 g_anPitchGoal[obj] = amount;
95 }
96}
97
98/* Function start: 0x41E6C8 */
99void prevent_collision(short obj)
100{
101 short timeToImpact;
102 short other;
103
104 other = g_acShipAlertSource[obj];
105 timeToImpact = 0;
106 if (other == -1) {
107 clear_alert(obj);
108 return;
109 }
110 timeToImpact = g_5_nCollisionCountdownNumber;
111 if (timeToImpact >= 30) {
114 return;
115 }
117 if (g_nFacingToTarget > 75) {
118 if (g_nTargetFacing < -70)
120 else
122 } else if (g_nFacingToTarget < -70 &&
123 normal_speed(obj) != 0) {
124 fire_afterburner(obj, 8);
125 } else {
127 }
128 if (CanSetNewShipTurnGoal(obj) != 0) {
129 if (g_nFacingToTarget < -60 &&
130 g_nTargetFacing > 60) {
131 veer_random(obj, 14);
132 } else {
134 obj, other, (short)(timeToImpact >> 1),
136 }
137 }
138}
139
140/* Function start: 0x41E860 */
141short handle_collisions(short obj)
142{
143 short other;
144
145 other = detect_collisions(obj);
146 if (other != -1)
147 start_collision_alert(obj, other);
148 if (alert_flag(obj, 1) != 0)
150 return alert_flag(obj, 1);
151}
152
153/* Function start: 0x41E8D3 */
155{
156 short count;
157 short obj;
158
159 count = 0;
160 for (obj = 0; obj < 10; obj++) {
162 g_asShipSide[obj] != g_asShipSide[0])
163 count++;
164 }
165 return count;
166}
167
168void position_relative(FixedVector *position, FixedVector direction, short distance);
169short scan_for_enemy(short obj, unsigned short range);
170short attacker_in_range(short obj, unsigned short range);
171
172/* Function start: 0x41E945 */
173short regulate_turn(short obj)
174{
175 if (g_aeSpecialManeuver[obj] ==
177 return 1;
178 g_acTurnRegulator[obj]--;
180 handle_collisions(obj) != 0)
181 return 1;
182 if ((g_nSpaceFrame & 1) != 0 &&
183 obj == g_nYourWingman &&
185 return 1;
187 GetAdaptiveTurnRate() >= 120 &&
188 CountEnemyFighters() < 3 &&
189 g_asShipSide[obj] != g_asShipSide[0])
190 g_acTurnRegulator[obj] = 0;
191 if (g_acTurnRegulator[obj] > 0)
192 return 1;
193 g_abShipTurn[obj]++;
195 return 0;
196}
197
198/* Function start: 0x41EA86 */
199unsigned int select_target(short obj)
200{
201 if (g_asShipSide[obj] == SIDE_KILRATHI &&
202 RandomBelow(100) < 50 && attacker_in_range(0, 16000) == 0 &&
203 distance_from_object(obj, 0) < 5000)
204 g_acShipTarget[obj] = 0;
205 else
206 g_acShipTarget[obj] =
207 (signed char)scan_for_enemy(obj, 16000);
208}
209
210/* Function start: 0x41EB1D */
211unsigned int veer_random(short obj, short amount)
212{
213 switch (RandomBelowOrEqual(3)) {
214 case 0:
215 g_anYawGoal[obj] = amount;
216 break;
217 case 1:
218 g_anYawGoal[obj] = -amount;
219 break;
220 case 2:
221 g_anPitchGoal[obj] = amount;
222 break;
223 case 3:
224 g_anPitchGoal[obj] = -amount;
225 break;
226 }
227}
228
229/* Function start: 0x41EBC1 */
230unsigned int offset_location(short obj, const ShortVector *offset,
231 FixedVector *location)
232{
233 *location = g_aShipPosition[obj];
235 offset->z);
236 position_relative(location, g_aShipUpVector[obj],
237 offset->y);
239 offset->x);
240}
241
242/* Function start: 0x41EC73 */
243unsigned int compute_formation_destination(short leader,
244 const ShortVector *offset,
245 FixedVector *destination)
246{
247 offset_location(leader, offset, destination);
248 AddFixedVectors(destination, &g_aShipVelocity[leader],
249 destination);
250 AddFixedVectors(destination, &g_aShipVelocity[leader],
251 destination);
252 AddFixedVectors(destination, &g_aShipVelocity[leader],
253 destination);
254}
255
256/* Function start: 0x41ECEF */
257void control_speed(short obj, unsigned short range, int desiredSpeed)
258{
259 unsigned short ticks;
260 int speedError;
261 int brakingMargin;
262 int reachableSpeed;
263
264 ticks = range /
266 reachableSpeed = GetShipAccelerationRate(obj) * ticks;
267 speedError = desiredSpeed - g_anShipSpeed[obj];
268 brakingMargin = reachableSpeed - AbsInt(speedError);
269 if (brakingMargin <= 0)
270 approach_speed(obj, desiredSpeed);
271 else if (brakingMargin < 12800)
272 celerate(obj, 0x100);
273 else
275}
276
277/* Function start: 0x41EDCC */
278void chase_location(short obj, const FixedVector *destination,
279 short reference)
280{
281 short pointAtDestination;
282 int speedGoal;
283 short facing;
284 FixedVector travel;
285 FixedVector projected;
286
287 pointAtDestination = 0;
288 speedGoal = g_anShipSpeed[reference] - 0x200;
289 if (speedGoal < 0)
290 speedGoal = 0;
292 g_anShipSpeed[reference] * 15,
293 &travel);
294 AddFixedVectors(destination, &travel, &projected);
295 get_facing_range_from_point(obj, &projected);
296 facing = g_nFacingToTarget;
297 get_facing_range_from_point(obj, destination);
298 if (g_nFacingToTarget < 0) {
299 approach_speed(obj, 0);
300 if (g_nTargetRange /
302 g_anShipSpeed[reference]), 1) > 49)
303 pointAtDestination = 1;
304 } else if (g_nTargetRange > 175 && CanSetNewShipTurnGoal(obj) != 0) {
305 pointAtDestination = 1;
306 }
307 control_speed(obj, (unsigned short)g_nTargetRange,
308 speedGoal);
309 if (g_nFacingToTarget > 85 &&
310 g_nTargetRange > 175)
311 g_anRollGoal[obj] =
312 match_roll_orientation(obj, reference);
313 if (pointAtDestination != 0)
314 point_ship(obj, 0, &g_vToTarget);
315 if (g_nTargetRange < 175) {
316 if (facing > 90) {
317 copy_frame(reference, obj);
318 steady_object(obj);
319 approach_speed(obj, g_anShipSpeed[reference]);
320 return;
321 } else
322 point_ship(obj, 0, &travel);
323 }
324 if (g_nTargetRange < 600)
325 trim_goals(obj, 10);
326}
327
328/* Function start: 0x41EFFE */
329void goto_location(short obj, const FixedVector *destination)
330{
331 get_facing_range_from_point(obj, destination);
332 if (g_nFacingToTarget < 51) {
334 if (CanSetNewShipTurnGoal(obj) != 0)
335 point_ship_at_point(obj, destination);
336 } else if (g_nTargetRange > 3000 ||
339 g_anShipSpeed[obj]),
340 1) > 50) {
342 } else {
344 }
345}
346
347/* Function start: 0x41F0C5 */
348void goto_formation(short obj, const FixedVector *destination,
349 short leader)
350{
351 short facingAhead;
352 FixedVector projected;
353
355 &g_aShipForwardVector[leader], &projected);
356 get_facing_range_from_point(obj, &projected);
357 facingAhead = g_nFacingToTarget;
358 get_facing_range_from_point(obj, destination);
359 if (g_nFacingToTarget < 40) {
361 } else if (g_nTargetRange > 2000) {
363 if (g_nTargetRange > 3000 &&
364 g_nFacingToTarget > 70 && normal_speed(obj) != 0)
365 fire_afterburner(obj, 5);
366 } else if (g_nTargetRange > 200) {
367 control_speed(obj, (unsigned short)g_nTargetRange,
368 g_anShipSpeed[leader]);
369 } else {
370 approach_ship_speed(obj, leader);
371 }
372 if (g_nTargetRange < 200) {
373 steady_object(obj);
374 if (facingAhead > 90) {
375 copy_frame(leader, obj);
376 return;
377 } else
378 point_parallel(obj, leader);
379 } else if (CanSetNewShipTurnGoal(obj) != 0) {
380 point_ship(obj, 0, &g_vToTarget);
381 }
382 if (g_nTargetRange < 700) {
383 trim_goals(obj, 10);
384 if (facingAhead > 90)
385 g_anRollGoal[obj] =
386 match_roll_orientation(obj, leader);
387 }
388}
389
390/* Function start: 0x41F2C5 */
391unsigned int maintain_formation(short obj)
392{
393 short leader;
394 FixedVector destination;
395
396 leader = g_asShipWingLeader[obj];
399 &destination);
400 g_aShipDestination[obj] = destination;
401 goto_formation(obj, &destination, leader);
402}
403
404/* Function start: 0x41F337 */
405unsigned int reset_stress(short obj)
406{
407 short stress;
408 short damage;
409
410 if (obj >= 12) {
411 if (g_acPilotAggression[g_asPilotLevel[obj]] == 0)
412 damage = 100;
413 else
414 damage = evaluate_damage(obj);
415 if (damage < 30) {
416 stress = 30;
417 } else if (damage < 75) {
418 stress = find_ratio(30, 74, damage, 29, 15);
419 } else {
420 stress = find_ratio(75, 100, damage, 14, 0);
421 }
422 g_acShipStress[obj] = (signed char)stress;
423 }
424}
425
426/* Function start: 0x41F3EF */
427short stress_morale(short obj)
428{
429 if (g_acShipStress[obj] < 15)
430 return 0;
431 else if (g_acShipStress[obj] < 30)
432 return 1;
433 else
434 return 2;
435}
436
437/* Function start: 0x41F446 */
438short any_defense(short obj)
439{
440 short count;
441 short skillLevel;
442 signed char *maneuvers;
443
444 count = 0;
445 skillLevel = g_asPilotLevel[obj];
446 if (skillLevel > 4)
447 skillLevel = 4;
448 maneuvers = g_apDefenseManeuvers[skillLevel];
449 while (maneuvers[count] != -1)
450 count++;
451 return maneuvers[RandomBelowOrEqual((short)(count - 1))];
452}
453
454/* Function start: 0x41F4C6 */
455short pick_regular_maneuver(short obj, short event)
456{
457 short reroll;
458
459 reroll = RandomBelowOrEqual(100) < 3 ||
461 if (stress_morale(obj) == 2)
462 return MANEUVER_OUTA_HERE;
463 if ((g_asIntelligenceEvent[obj] == event ||
464 RandomBelowOrEqual(100) < 20) &&
465 (event == 0 || event == 3 || event == 4 || event == 7) &&
466 reroll == 0)
467 return g_asShipManeuver[obj];
468
469 switch (event) {
470 case 0:
471 case 1:
472 if (g_aeObjectClass[
473 g_acShipTarget[obj]] >=
476 if (g_asPilotLevel[obj] * 5 + 60 > RandomBelow(100))
477 return MANEUVER_ZIP_PAST;
478 return any_defense(obj);
479 case 3:
480 return any_defense(obj);
481 case 2:
482 return MANEUVER_TRY2TAIL;
483 case 4:
484 return RandomBelowOrEqual(100) >=
485 g_asPilotLevel[obj] * 20 + 30
486 ? any_defense(obj)
488 case 5:
489 return MANEUVER_TAIL_FIRE;
490 case 6:
491 if (g_asPilotLevel[obj] >= 2)
492 return MANEUVER_HARD_TURN;
493 else
494 return MANEUVER_WABBLE;
495 case 7:
496 return any_defense(obj);
497 case 8:
499 }
500 return MANEUVER_ROLL_OVER;
501}
502
503short RandomBelow(short n);
504
505/* Function start: 0x41F714 */
506short pick_from_list(const ManeuverChoice *choice, short obj,
507 short event)
508{
509 short maneuver;
510 short chooseAgain;
511
512 maneuver = g_asShipManeuver[obj];
513 if (maneuver == MANEUVER_NONE)
514 chooseAgain = 1;
515 else
516 chooseAgain = 0;
517 if (((choice->primary != maneuver &&
518 choice->secondary != maneuver &&
519 RandomBelow(100) < 10) ||
520 g_asIntelligenceEvent[obj] != event) &&
521 choice->primary < MANEUVER_UNKNOWN_48 &&
523 chooseAgain = 1;
524 if (chooseAgain == 0) {
525 if (RandomBelowOrEqual(100) < 5)
526 chooseAgain = 1;
527 }
528 if (chooseAgain != 0) {
529 if (RandomBelowOrEqual(99) >= choice->threshold)
530 maneuver = choice->secondary;
531 else
532 maneuver = choice->primary;
533 }
534 return maneuver;
535}
536
537/* Function start: 0x41F83F */
538short pick_kilrathi_maneuver(short obj, short event)
539{
540 const ManeuverChoice *choice;
541 short maneuver;
542
543 choice = &((const ManeuverChoice (*)[9][3])
545 g_asShipIntelSlot[obj]][event][stress_morale(obj)];
546 maneuver = pick_from_list(choice, obj, (short)event);
547 switch (maneuver) {
549 maneuver = MANEUVER_STRAFE_ENEMY;
550 if (event == 5)
551 maneuver = MANEUVER_ZIP_PAST;
552 break;
554 maneuver = any_defense(obj);
555 break;
556 }
557 return maneuver;
558}
559
560/* Function start: 0x41F902 */
561/* How many earlier ships on this ship's side are already pressing the same
562 * target while its intelligence event is 5. */
564{
565 short count;
566 short other;
567
568 count = 0;
569 for (other = 1; other < obj; other++) {
570 if (g_aeObjectClass[other] == OBJECT_CLASS_SHIP &&
571 g_asShipSide[other] == g_asShipSide[obj] &&
572 g_acShipTarget[other] == g_acShipTarget[obj] &&
573 g_asIntelligenceEvent[obj] == 5)
574 count++;
575 }
576 return count;
577}
578
579/* Function start: 0x41F9AF */
580void process_maneuver_node(short obj, short event)
581{
582 const ManeuverChoice *choice;
583 short maneuver;
584 short index;
585
586 maneuver = (short)g_asShipManeuver[obj];
588 if (g_asPilotLevel[obj] < 5 ||
589 (g_asShipSide[obj] == 0 &&
590 g_nYourWingman != obj)) {
591 if (g_asShipSide[obj] == 1)
592 maneuver = (short)pick_kilrathi_maneuver(obj, event);
593 else
594 maneuver = pick_regular_maneuver(obj, event);
595 } else {
596 choice = &((const ManeuverChoice (*)[9][3])
598 g_asShipIntelSlot[obj]][event][stress_morale(obj)];
599 maneuver = (short)pick_from_list(choice, obj, (short)event);
600 }
601
602 if (g_asShipSide[obj] == 1 &&
603 g_nFacingToTarget > 0x61 &&
604 g_nTargetRange < 4000)
605 fire(obj, g_acShipTarget[obj]);
606
607 if (g_nYourWingman == obj) {
608 for (index = 0; index < 8; index++) {
611 break;
612 }
613 if (g_4_acInitialShipKillNumber[index] <
616 else
618 }
619
620 if ((event == 3 || event == 7) &&
621 g_nTargetRange < 2000 &&
622 g_nTargetFacing > 0x5e)
623 fire_afterburner(obj, 10);
624
625 if ((g_asShipSide[obj] != g_asShipSide[0] &&
626 GetAdaptiveTurnRate() > 0x78) ||
627 (g_asShipSide[obj] == g_asShipSide[0] &&
629 if (g_acShipTarget[obj] != -1 && event != 4 &&
631 g_acShipTarget[obj]] == 1)
632 fire_afterburner(obj, 10);
633
634 if (event != 5 &&
635 g_asShipCloakCooldown[obj] == 0 &&
636 g_anShipCloakState[obj] == 0)
637 maneuver = 0x2f;
638 }
639
640 if (g_asProjectileEvasionTicks[obj] > 0)
641 maneuver = 0x2e;
642
643 if (maneuver == 0x28 && CountAlliesOnSameTarget(obj) > 1) {
644 if (event == 5)
645 maneuver = 0x2e;
646 else
647 maneuver = 0x12;
648 }
649 if (g_asShipManeuver[obj] != maneuver)
650 reset_maneuver(obj, maneuver);
651}
652
653/* Function start: 0x41FD2B */
654void handle_stress(short obj, short event)
655{
656 short aggressiveness;
657 short damage;
658
659 aggressiveness =
661 switch (event) {
662 case -1:
663 case 2:
664 g_acShipStress[obj] -=
666 break;
667 case 6:
668 g_acShipStress[obj] += aggressiveness * 2;
669 break;
670 case 8:
671 g_acShipStress[obj] /= 2;
672 break;
673 case 5:
674 g_acShipStress[obj] -= aggressiveness;
675 break;
676 case 3:
677 case 4:
678 case 7:
679 g_acShipStress[obj] += aggressiveness;
680 break;
681 case 0:
682 break;
683 }
684 damage = evaluate_damage(obj);
685 if (damage < 40) {
686 g_acShipStress[obj] += aggressiveness * 2;
687 } else if (damage < 75) {
688 g_acShipStress[obj] =
689 (signed char)MinShort(
690 (short)((short)g_acShipStress[obj] + aggressiveness),
691 28);
692 } else {
693 g_acShipStress[obj] =
694 (signed char)MinShort(g_acShipStress[obj], 7);
695 }
696 if (event == 6 && g_acShipStress[obj] >= 30)
697 g_acShipStress[obj] = 29;
698 if (g_acShipStress[obj] < 0)
699 g_acShipStress[obj] = 0;
700}
701
702/* The unnamed parameter preserves later C1 symbol keys after case 0. */
703void handle_stress(short obj, short);
704unsigned int reset_objective(short ship, short objective);
705unsigned int reset_stress(short obj);
706
707/* Function start: 0x41FF37 */
708void intelligence_events(short obj)
709{
710 short event;
711 short targetGone;
712 short target;
713 short previousStress;
714 short damageLevel;
715
716 event = -1;
717 target = g_acShipTarget[obj];
718 previousStress = (short)g_acShipStress[obj];
719 targetGone = 0;
720 if (unactive(target) == 0) {
723 g_acShipTarget[obj]] ==
725 event = 8;
726 } else {
727 event = 0;
728 if (g_nTargetRange > 8000) {
729 event = 2;
730 } else if (g_nFacingToTarget > 55 &&
731 g_nTargetFacing < -55) {
732 event = 5;
733 } else if (g_nFacingToTarget > 75 &&
734 g_nTargetFacing > 75 &&
735 g_nTargetRange < 5000) {
736 event = 4;
737 if (g_acShipCollisionCooldown[obj] > 0 &&
738 g_asObjectDamage[obj] > 0)
739 event = 7;
740 } else if (FindMissileTargetingObject(obj) != 0) {
741 event = 6;
742 } else if (g_acShipCollisionCooldown[obj] > 0) {
743 event = 7;
744 } else if (g_nFacingToTarget < -70 &&
745 g_nTargetFacing > 90 &&
746 g_nTargetRange < 4000 &&
747 g_nTargetRange < 5000) {
748 event = 3;
749 if (g_asShipSide[obj] == SIDE_KILRATHI &&
750 GetAdaptiveTurnRate() <= 30)
751 event = 0;
752 } else if (g_anShipSpeed[target] < 5120) {
753 event = 1;
754 }
755 }
756 } else if (FindMissileTargetingObject(obj) != 0) {
757 event = 6;
758 } else if (g_acShipCollisionCooldown[obj] > 0) {
759 event = 7;
760 } else {
761 targetGone = 1;
762 }
763
764 handle_stress(obj, event);
765 if (event != -1)
766 process_maneuver_node(obj, event);
767 if (event == -1 && targetGone != 0) {
768 if (any_enemy(obj, 16000) == 0)
770 else
771 select_target(obj);
772 reset_stress(obj);
773 }
774
775 if (g_nYourWingman == obj &&
778 if (previousStress < 15 && g_acShipStress[obj] >= 15 &&
779 RandomBelowOrEqual(3) == 0) {
780 send_message(obj, 4);
781 } else {
782 damageLevel = evaluate_damage(0);
783 if (RandomBelow(1000) < 4 && damageLevel < 35) {
784 if (evaluate_damage(obj) > damageLevel)
785 send_message(obj, 10);
786 else
787 send_message(obj, 4);
788 }
789 }
790 }
791 g_asIntelligenceEvent[obj] = event;
792}
793
794/* Linker commons defined here. LINK lays a unit's commons out by the
795 * identifiers' hash keys, so these spellings follow the original addresses. */
796unsigned char g_aShipIntelligenceData[5][0x51]; /* 0x005d3060 */
void clear_alert(short obj)
Definition logic.c:37
unsigned int approach_full_speed(short ship)
Definition logic.c:537
short match_roll_orientation(short obj, short reference)
Definition geom.c:604
void transform_to_objects_frame(const FixedVector *source, FixedVector *destination, short obj)
Definition geom.c:495
short CountAlliesOnSameTarget(short obj)
Definition smart.c:563
void ComputeVectorDelta(FixedVector *from, FixedVector *to, FixedVector *delta)
Definition geom.c:229
unsigned int approach_zero_speed(short ship)
Definition logic.c:508
short regulate_turn(short obj)
Definition smart.c:173
unsigned int select_target(short obj)
Definition smart.c:199
void get_facing_range_from_point(short obj, const FixedVector *point)
Definition geom.c:562
short MaxShort(short a, short b)
Definition disk.c:36
void goto_location(short obj, const FixedVector *destination)
Definition smart.c:329
short detect_collisions(short obj)
Definition logic.c:143
void steer_away_from_object(short obj, short other, short amount)
Definition smart.c:40
void fire_afterburner(short obj, short time)
Definition ship.c:2733
void AddFixedVectors(const FixedVector *left, const FixedVector *right, FixedVector *sum)
Definition geom.c:211
short evaluate_damage(short obj)
Definition logic.c:1027
unsigned int reset_stress(short obj)
Definition smart.c:405
signed char CanSetNewShipTurnGoal(short ship)
Definition logic.c:303
short unactive(short ship)
Definition logic.c:186
void ScaleFixedVector(FixedVector *vector, int scale, FixedVector *result)
Definition geom.c:237
short FixedToShortSaturating(int value)
Definition geom.c:122
void process_maneuver_node(short obj, short event)
Definition smart.c:580
short MinShort(short a, short b)
Definition disk.c:27
void steer_away_from_predicted_object(short obj, short other, short predictionTicks, short amount)
Definition smart.c:72
void intelligence_events(int obj)
short any_enemy(short obj, short range)
Definition logic.c:610
short find_ratio(short inputMinimum, short inputMaximum, short input, short outputMinimum, short outputMaximum)
Definition logic.c:1013
short scan_for_enemy(short obj, unsigned short range)
Definition logic.c:576
unsigned int offset_location(short obj, const ShortVector *offset, FixedVector *location)
Definition smart.c:230
void goto_formation(short obj, const FixedVector *destination, short leader)
Definition smart.c:348
void point_ship(short obj, short turnRate, const FixedVector *direction)
Definition geom.c:667
unsigned int approach_ship_speed(short obj, short other)
Definition logic.c:544
short distance_from_object(short obj, short other)
Definition geom.c:547
unsigned int approach_speed(short ship, int targetSpeed)
Definition ship.c:682
void try2end_collision_alert(short obj)
Definition logic.c:58
void copy_frame(short source, short destination)
Definition geom.c:470
unsigned int maintain_formation(int obj)
void steady_object(short ship)
Definition ship.c:698
short attacker_in_range(short obj, unsigned short range)
Definition logic.c:664
void handle_stress(short obj, short event)
Definition smart.c:654
short GetAdaptiveTurnRate(void)
Definition ship.c:137
unsigned int reset_objective(short ship, short objective)
Definition logic.c:445
short handle_collisions(short obj)
Definition smart.c:141
int AbsInt(int v)
Definition geom.c:151
short CountEnemyFighters(void)
Definition smart.c:154
void control_speed(short obj, unsigned short range, int desiredSpeed)
Definition smart.c:257
void chase_location(short obj, const FixedVector *destination, short reference)
Definition smart.c:278
short any_defense(short obj)
Definition smart.c:438
short RandomBelow(short n)
Definition eventmgr.c:12
void trim_goals(short obj, short amount)
Definition logic.c:201
void position_relative(FixedVector *position, FixedVector direction, short distance)
Definition geom.c:101
unsigned int approach_min_speed(short obj)
Definition logic.c:514
unsigned int veer_random(short obj, short amount)
Definition smart.c:211
short FindMissileTargetingObject(short obj)
Definition logic.c:357
void get_facing_range_from_object(short obj, short other)
Definition geom.c:578
void start_collision_alert(short obj, short other)
Definition logic.c:45
unsigned int approach_cruise_speed(short ship)
Definition logic.c:529
void fire(short obj, short target)
Definition ship.c:2059
void send_message(short obj, signed char message)
Definition cockpt.c:3116
short pick_regular_maneuver(short obj, short event)
Definition smart.c:455
short pick_from_list(const ManeuverChoice *choice, short obj, short event)
Definition smart.c:506
void celerate(short ship, int delta)
Definition ship.c:668
void approach_half_speed(short obj)
Definition logic.c:520
short pick_kilrathi_maneuver(short obj, short event)
Definition smart.c:538
void prevent_collision(short obj)
Definition smart.c:99
short normal_speed(short obj)
Definition logic.c:68
unsigned int compute_formation_destination(short leader, const ShortVector *offset, FixedVector *destination)
Definition smart.c:243
void point_ship_at_point(short obj, const FixedVector *point)
Definition geom.c:676
void point_parallel(short obj, short other)
Definition geom.c:740
void reset_maneuver(short ship, short maneuver)
Definition logic.c:476
short RandomBelowOrEqual(short n)
Definition eventmgr.c:43
short stress_morale(short obj)
Definition smart.c:427
short alert_flag(short ship, unsigned int bits)
Definition logic.c:25
int GetShipAccelerationRate(short ship)
Definition geom.c:62
Shared Win32 declarations, types and library interfaces.
@ SIDE_KILRATHI
Definition game_data.h:176
@ OBJECTIVE_NONE
Definition game_data.h:138
@ SPECIAL_MANEUVER_UNKNOWN_9
Definition game_data.h:269
@ MANEUVER_ZIP_PAST
Definition game_data.h:249
@ MANEUVER_WABBLE
Definition game_data.h:222
@ MANEUVER_OUTA_HERE
Definition game_data.h:230
@ MANEUVER_ROLL_OVER
Definition game_data.h:223
@ MANEUVER_HARD_TURN
Definition game_data.h:224
@ MANEUVER_UNKNOWN_49
Definition game_data.h:255
@ MANEUVER_TAIL_FIRE
Definition game_data.h:235
@ MANEUVER_TRY2TAIL
Definition game_data.h:248
@ MANEUVER_NONE
Definition game_data.h:208
@ MANEUVER_LINE_UP_DROP
Definition game_data.h:251
@ MANEUVER_STRAFE_ENEMY
Definition game_data.h:238
@ MANEUVER_UNKNOWN_48
Definition game_data.h:254
@ OBJECT_CLASS_SHIP
Definition game_data.h:49
@ OBJECT_CLASS_CAPITAL_SHIP
Definition game_data.h:50
short g_asShipCloakCooldown[10]
Definition viewrect.c:180
short g_asProjectileEvasionTicks[8]
Definition viewrect.c:186
ShortVector g_aShipFormationOffset[10]
Definition viewrect.c:129
signed char g_aDefenseManeuversElite[16]
Definition smart.c:14
short g_nYourWingman
Definition viewrect.c:75
FixedVector g_vToTarget
Definition viewrect.c:44
short g_asPilotLevel[12]
Definition viewrect.c:157
short g_nFacingToTarget
Definition viewrect.c:45
unsigned char g_aShipIntelligenceData[5][0x51]
Definition smart.c:796
short g_aeObjectClass[SPACE_OBJECT_COUNT]
Definition viewrect.c:125
signed char g_acShipTarget[16]
Definition viewrect.c:167
short g_anRollGoal[12]
Definition viewrect.c:132
signed char g_acShipCollisionCooldown[16]
Definition viewrect.c:178
FixedVector g_aShipForwardVector[SPACE_OBJECT_COUNT]
Definition viewrect.c:107
signed char g_aDefenseManeuversAce[16]
Definition smart.c:17
short g_asShipIntelSlot[10]
Definition viewrect.c:155
short g_aeSpecialManeuver[12]
Definition viewrect.c:141
FixedVector g_aShipRightVector[SPACE_OBJECT_COUNT]
Definition viewrect.c:105
short g_anYawGoal[12]
Definition viewrect.c:131
signed char g_acTurnInterval[16]
Definition viewrect.c:143
signed char g_acPilotRecovery[8]
Definition smart.c:33
signed char g_aDefenseManeuversBoss[16]
Definition smart.c:20
short g_nSpaceFrame
Definition viewrect.c:32
short g_asObjectDamage[SPACE_OBJECT_COUNT]
Definition viewrect.c:121
short g_nTargetFacing
Definition viewrect.c:46
short g_anPitchGoal[12]
Definition viewrect.c:130
int g_anShipSpeed[SPACE_OBJECT_COUNT]
Definition viewrect.c:116
signed char * g_apDefenseManeuvers[5]
Definition smart.c:23
signed char g_acPilotAggression[8]
Definition smart.c:30
signed char g_36_cPilotKillCountValue
Definition gameflow.c:3811
short g_asShipWingLeader[12]
Definition viewrect.c:162
short g_5_nCollisionCountdownNumber
Definition logic.c:1053
int g_anShipCloakState[10]
Definition viewrect.c:179
signed char g_acShipPendingMessage[16]
Definition viewrect.c:160
signed char g_4_acInitialShipKillNumber[8]
Definition logic.c:1056
FixedVector g_aShipPosition[SPACE_OBJECT_COUNT]
Definition viewrect.c:108
signed char g_aDefenseManeuversVeteran[8]
Definition smart.c:11
FixedVector g_aShipUpVector[SPACE_OBJECT_COUNT]
Definition viewrect.c:106
short g_asShipManeuver[12]
Definition viewrect.c:169
FixedVector g_aShipVelocity[SPACE_OBJECT_COUNT]
Definition viewrect.c:109
short g_asShipMissionIndex[12]
Definition viewrect.c:153
signed char g_acShipAlertSource[12]
Definition viewrect.c:173
signed char g_acTurnRegulator[16]
Definition viewrect.c:142
signed char g_acShipStress[16]
Definition viewrect.c:187
signed char g_abShipTurn[16]
Definition viewrect.c:175
FixedVector g_aShipDestination[10]
Definition viewrect.c:128
short g_bWingmanTurnRateUnlocked
Definition smart.c:36
short g_nTargetRange
Definition viewrect.c:47
short g_asIntelligenceEvent[12]
Definition spc.c:16
short g_asShipSide[12]
Definition viewrect.c:139
signed char g_aDefenseManeuversNovice[8]
Definition smart.c:8
MissionHeader g_13_stMissionHeaderBlock
Definition hotspot.c:253
signed char secondary
Definition game_data.h:1248
signed char threshold
Definition game_data.h:1246
signed char primary
Definition game_data.h:1247
short initialMissionShips[8]
Definition game_data.h:1347