Wing Commander
Reconstructed Win32 source (1996)
Loading...
Searching...
No Matches
targ.c
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup flight
4 * @brief Objective arrival, warp transitions, mines and cockpit cleanup.
5 *
6 * Address range 42a8f0-42acff, corroborated by the Mac targ symbols.
7 */
8#include "wc1.h"
9#include <process.h>
10
11/* Linker commons defined here; LINK orders them by identifier hash. */
16short asDamageFlashColour[3]; /* 0x005a7780 */
17short nCurrentDmgDispTicks; /* 0x005a7786 */
18ShortPoint stWpnDispOrigin; /* 0x005a7788 */
19char szDmgStateText[0x48]; /* 0x005a7790 */
21signed char cDamageDisplayComponentValue; /* 0x005a77dc */
22signed char cDamageDisplayFrame; /* 0x005a77dd */
23signed char cDamagedComponentCount; /* 0x005a77de */
24
25/* Function start: 0x42A8F0 */
26short find_objective(int type, short index)
27{
28 short objective;
29
30 for (objective = 0; objective < (short)cMissionObjectiveCountValue; objective++) {
31 if (aMissionObjectivesArray[objective].type == type) {
32 if (index == -1)
33 return objective;
34 if (aMissionObjectivesArray[objective].index == index)
35 return objective;
36 }
37 }
38 return -1;
39}
40
41/* Function start: 0x42A950 */
42void arrive_from_warp(short obj)
43{
44 short objective = find_objective(0, nCurrentNavigationPoint);
45
46 if (objective != -1) {
48 abFlightPathList[objective]].type != 1)
49 flag_objective(objective, 1);
50 if (cCurrentObjective == objective)
52 }
53 approve_xyz(obj, 2000, 5000);
54 unwarp(obj);
55 anShipSpeed[obj] =
56 (int)asShipMaximumSpeedArray[obj] << 8;
57 fix_velocity(obj);
58 if (aeShipSide[obj] == SIDE_IMPERIAL)
60 else
62}
63
64/* Function start: 0x42AA10 */
65unsigned int unwarp(short obj)
66{
67 short effect;
68
71 effect = find_vacant_3d_object();
72 if (effect != -1) {
75 aShipVelocity[effect] = aShipVelocity[obj];
77 asObjectCounterArray[obj] = 6;
78 return 0;
79 }
80 abShipNavPtIdx[obj] =
81 (signed char)aeObjectTypeList[obj];
83 return 0;
84}
85
86/* Function start: 0x42AAF0 */
87unsigned int warp(short obj)
88{
89 short effect;
90
93 effect = find_vacant_3d_object();
94 if (effect != -1) {
96 acObjOwnersTable[obj]);
98 aShipVelocity[effect] = aShipVelocity[obj];
100 asObjectCounterArray[obj] = 6;
101 return 0;
102 }
104 acObjOwnersTable[obj]);
105 return 0;
106}
107
108/* Function start: 0x42ABD0 */
109int drop_player_mine(short obj)
110{
111 enum ObjectType type;
112 short weapon;
113
114 for (weapon = 0; weapon < aShipWeaponsTable[obj][0]; weapon++) {
115 type = ((ShipWeaponSlot *)&aShipWeaponsTable[obj][1])[weapon].type;
116 if (aObjectTypeData[type].objectClass == OBJECT_CLASS_MINE &&
117 ((ShipWeaponSlot *)&aShipWeaponsTable[obj][1])[weapon].disabled == 0)
118 return drop_mine(obj, (signed char)weapon, type, 20);
119 }
120 return -1;
121}
122
123/* Function start: 0x42AC50 */
124unsigned int personality_killed(short personality)
125{
126 if (personality < 8) {
131 0, (short)(stCampaignState.promotionScore - 1));
132 return 0;
133 }
134 kill_ace((short)(personality - 9));
137 return 0;
138}
139
140/* Function start: 0x42ACC0 */
TextContext stRightVduTxtContext
Definition targ.c:12
enum Side aeShipSide[12]
Definition ending.c:22
signed char cDamagedComponentCount
Definition targ.c:23
signed char aShipWeaponsTable[10][0x47]
Definition dib.c:108
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
TextContext stDefaultTxtContext
Definition targ.c:14
signed char cMissionObjectiveCountValue
Definition game.c:554
unsigned char cViewportClearColour
Definition init.c:13
signed char abFlightPathList[MISSION_OBJECTIVE_COUNT]
Definition smart.c:20
short asShipMaximumSpeedArray[16]
Definition game.c:552
int bViewportDirty
Definition main.c:27
TextContext stCurrentConvTxtCtx
Definition targ.c:15
TextContext stCurrentCockpitReadoutTextCtx
Definition targ.c:13
ShortPoint stDamageSpritePos
Definition targ.c:20
short nYourWingman
Definition game.c:61
signed char cDamageDisplayFrame
Definition targ.c:22
FixedVector aShipVelocity[SPACE_OBJECT_COUNT]
Definition smart.c:21
signed char cDamageDisplayComponentValue
Definition targ.c:21
int anShipSpeed[64]
Definition data.c:248
short asDamageFlashColour[3]
Definition targ.c:16
Viewport stSpaceBufferViewport
Definition timer.c:13
short asObjectCounterArray[SPACE_OBJECT_COUNT]
Definition game.c:547
signed char cCurrentObjective
Definition game.c:37
CampaignState stCampaignState
Definition dib.c:107
signed char acObjOwnersTable[64]
Definition joycal.c:29
MissionObjective aMissionObjectivesArray[MISSION_OBJECTIVE_COUNT]
Definition screen.c:24
short nCurrentNavigationPoint
Definition music.c:90
enum ObjectType aeObjectTypeList[SPACE_OBJECT_COUNT]
Definition data.c:255
char szDmgStateText[0x48]
Definition targ.c:19
FixedVector aShipPositionsArray[SPACE_OBJECT_COUNT]
Definition game.c:556
signed char acShipTargetTable[16]
Definition joycal.c:30
ShortPoint stWpnDispOrigin
Definition targ.c:18
short nCurrentDmgDispTicks
Definition targ.c:17
short nAutoEngageTimer
Definition game.c:104
short nTargetLockMode
Definition game.c:95
short missionScore
Definition wcdata.h:723
short promotionScore
Definition wcdata.h:722
signed char currentSeries
Definition wcdata.h:715
int personalityDeathMission[8]
Definition wcdata.h:718
signed char currentMission
Definition wcdata.h:714
Umbrella header for the game core.
void approve_xyz(short obj, short minimum, short maximum)
Definition mission.c:676
unsigned int reset_objective(short ship, enum ShipObjective objective)
Definition logic.c:676
void set_next_destination(void)
Definition cockpt.c:1179
void kill_ace(short ace)
Definition logic.c:133
int drop_mine(short obj, signed char weapon, enum ObjectType type, short lifetime)
Definition ship.c:1951
unsigned int warp(short obj)
Definition targ.c:87
void set_objects_data(short obj, enum ObjectType type, short owner)
Definition ship.c:173
unsigned int personality_killed(short personality)
Definition targ.c:124
void ClearHudGunReadouts(void)
Definition cockpt.c:433
short find_objective(int type, short index)
Definition targ.c:26
unsigned int fix_velocity(short obj)
Definition ship.c:438
void ClearViewport(Viewport *viewport, short colour)
Definition gr.c:963
short find_vacant_3d_object(void)
Definition geom.c:987
int drop_player_mine(short obj)
Definition targ.c:109
unsigned int unwarp(short obj)
Definition targ.c:65
void arrive_from_warp(short obj)
Definition targ.c:42
void flag_objective(short objective, unsigned char flags)
Definition cockpt.c:1048
unsigned int reset_mission_type(short obj, enum ShipMissionType missionType)
Definition logic.c:653
short MaxShort(short a, short b,...)
Definition mathutil.c:29
void clean_up_cockpit(void)
Definition targ.c:141
@ MISSION_TYPE_PATROL
Definition wcdata.h:122
@ MISSION_TYPE_COME_HOME
Definition wcdata.h:132
ObjectType
Definition wcdata.h:54
@ OBJECT_TYPE_HYPERSPACE_JUMP_FLASH
Definition wcdata.h:112
@ SIDE_IMPERIAL
Definition wcdata.h:174
@ OBJECTIVE_HOLD_FORMATION
Definition wcdata.h:146
@ MANEUVER_WARPING_OUT
Definition wcdata.h:209
@ MANEUVER_NONE
Definition wcdata.h:207
@ OBJECT_CLASS_MINE
Definition wcdata.h:48