2 * Copyright (C) Volition, Inc. 1999. All rights reserved.
4 * All source code herein is the property of Volition, Inc. You may not sell
5 * or otherwise commercially exploit the source or things you created based on
10 * $Logfile: /Freespace2/code/Ship/Ship.h $
15 * all sorts of cool stuff about ships
18 * Revision 1.3 2003/05/25 02:30:42 taylor
21 * Revision 1.2 2002/06/09 04:41:14 relnev
22 * added copyright header
24 * Revision 1.1.1.1 2002/05/03 03:28:12 root
28 * 73 9/01/99 10:15a Dave
30 * 72 8/30/99 5:01p Dave
31 * Made d3d do less state changing in the nebula. Use new chat server for
34 * 71 8/27/99 9:07p Dave
35 * LOD explosions. Improved beam weapon accuracy.
37 * 70 8/26/99 8:52p Dave
38 * Gave multiplayer TvT messaging a heavy dose of sanity. Cheat codes.
40 * 69 8/18/99 12:09p Andsager
41 * Add debug if message has no anim for message. Make messages come from
44 * 68 8/16/99 10:04p Andsager
45 * Add special-warp-dist and special-warpout-name sexp for Knossos device
48 * 67 8/16/99 2:01p Andsager
49 * Knossos warp-in warp-out.
51 * 66 8/13/99 10:49a Andsager
52 * Knossos and HUGE ship warp out. HUGE ship warp in. Stealth search
53 * modes dont collide big ships.
55 * 65 8/02/99 10:39p Dave
56 * Added colored shields. OoOoOoooOoo
58 * 64 7/28/99 1:36p Andsager
59 * Modify cargo1 to include flag CARGO_NO_DEPLETE. Add sexp
60 * cargo-no-deplete (only for BIG / HUGE). Modify ship struct to pack
63 * 63 7/26/99 8:06a Andsager
66 * 62 7/19/99 8:56p Andsager
67 * Added Ship_exited red_alert_carry flag and hull strength for RED ALERT
68 * carry over of Exited_ships
70 * 61 7/18/99 5:20p Dave
71 * Jump node icon. Fixed debris fogging. Framerate warning stuff.
73 * 60 7/15/99 9:20a Andsager
74 * FS2_DEMO initial checkin
76 * 59 7/09/99 5:54p Dave
77 * Seperated cruiser types into individual types. Added tons of new
78 * briefing icons. Campaign screen.
80 * 58 7/08/99 12:06p Andsager
81 * Add turret-tagged-only and turret-tagged-clear sexp.
83 * 57 7/08/99 11:45a Dave
84 * Bumped up max ship types.
86 * 56 7/08/99 10:53a Dave
87 * New multiplayer interpolation scheme. Not 100% done yet, but still
88 * better than the old way.
90 * 55 7/06/99 10:45a Andsager
91 * Modify engine wash to work on any ship that is not small. Add AWACS
94 * 54 7/01/99 4:23p Dave
95 * Full support for multiple linked ambient engine sounds. Added "big
98 * 53 7/01/99 11:44a Dave
99 * Updated object sound system to allow multiple obj sounds per ship.
100 * Added hit-by-beam sound. Added killed by beam sound.
102 * 52 6/30/99 5:53p Dave
103 * Put in new anti-camper code.
105 * 51 6/14/99 3:21p Andsager
106 * Allow collisions between ship and its debris. Fix up collision pairs
107 * when large ship is warping out.
109 * 50 6/07/99 4:21p Andsager
110 * Add HUD color for tagged object. Apply to target and radar.
112 * 49 6/03/99 11:43a Dave
113 * Added the ability to use a different model when rendering to the HUD
116 * 48 6/01/99 8:35p Dave
117 * Finished lockarm weapons. Added proper supercap weapons/damage. Added
118 * awacs-set-radius sexpression.
120 * 47 5/28/99 9:26a Andsager
121 * Added check_world_pt_in_expanded_ship_bbox() function
123 * 46 5/26/99 11:46a Dave
124 * Added ship-blasting lighting and made the randomization of lighting
125 * much more customizable.
127 * 45 5/21/99 5:03p Andsager
128 * Add code to display engine wash death. Modify ship_kill_packet
130 * 44 5/20/99 7:00p Dave
131 * Added alternate type names for ships. Changed swarm missile table
134 * 43 5/14/99 11:50a Andsager
135 * Added vaporize for SMALL ships hit by HUGE beams. Modified dying
136 * frame. Enlarged debris shards and range at which visible.
138 * 42 5/12/99 2:55p Andsager
139 * Implemented level 2 tag as priority in turret object selection
141 * 41 5/11/99 10:16p Andsager
142 * First pass on engine wash effect. Rotation (control input), damage,
145 * 40 4/28/99 3:11p Andsager
146 * Stagger turret weapon fire times. Make turrets smarter when target is
147 * protected or beam protected. Add weaopn range to weapon info struct.
149 * 39 4/28/99 9:39a Andsager
150 * flag for ship_weapon turret lock
152 * 38 4/23/99 12:01p Johnson
153 * Added SIF_HUGE_SHIP
155 * 37 4/20/99 6:39p Dave
156 * Almost done with artillery targeting. Added support for downloading
157 * images on the PXO screen.
159 * 36 4/19/99 11:01p Dave
160 * More sophisticated targeting laser support. Temporary checkin.
162 * 35 4/19/99 12:21p Johnson
163 * Allow ships with invisible polygons which do not collide
165 * 34 4/16/99 5:54p Dave
166 * Support for on/off style "stream" weapons. Real early support for
167 * target-painting lasers.
169 * 33 4/12/99 10:07p Dave
170 * Made network startup more forgiving. Added checkmarks to dogfight
171 * screen for players who hit commit.
173 * 32 4/02/99 9:55a Dave
174 * Added a few more options in the weapons.tbl for beam weapons. Attempt
175 * at putting "pain" packets into multiplayer.
177 * 31 3/31/99 8:24p Dave
178 * Beefed up all kinds of stuff, incluging beam weapons, nebula effects
179 * and background nebulae. Added per-ship non-dimming pixel colors.
181 * 30 3/30/99 5:40p Dave
182 * Fixed reinforcements for TvT in multiplayer.
184 * 29 3/28/99 5:58p Dave
185 * Added early demo code. Make objects move. Nice and framerate
186 * independant, but not much else. Don't use yet unless you're me :)
188 * 28 3/20/99 3:46p Dave
189 * Added support for model-based background nebulae. Added 3 new
192 * 27 3/08/99 7:03p Dave
193 * First run of new object update system. Looks very promising.
195 * 26 3/04/99 6:09p Dave
196 * Added in sexpressions for firing beams and checking for if a ship is
199 * 25 3/02/99 9:25p Dave
200 * Added a bunch of model rendering debug code. Started work on fixing
201 * beam weapon wacky firing.
203 * 24 3/01/99 7:39p Dave
204 * Added prioritizing ship respawns. Also fixed respawns in TvT so teams
205 * don't mix respawn points.
207 * 23 2/26/99 6:01p Andsager
208 * Add sexp has-been-tagged-delay and cap-subsys-cargo-known-delay
210 * 22 2/26/99 4:14p Dave
211 * Put in the ability to have multiple shockwaves for ships.
213 * 21 2/11/99 5:22p Andsager
214 * Fixed bugs, generalized block Sexp_variables
216 * 20 2/11/99 2:15p Andsager
217 * Add ship explosion modification to FRED
219 * 19 2/03/99 6:06p Dave
220 * Groundwork for FS2 PXO usertracker support. Gametracker support next.
228 #include "parselo.h" // for defintions of token lengths -- maybe move this elsewhere later
230 #include "2d.h" // for color def
231 #include "multi_obj.h"
237 // Part of the player died system.
238 extern vector Dead_camera_pos, Original_vec_to_deader;
240 // States for player death sequence, stuffed in Player_died_state.
243 #define PDS_EJECTED 3
247 #define MAX_SHIPS 100 // max number of ship instances there can be.
248 #define SHIPS_LIMIT 100 // what MAX_SHIPS will be at release time (for error checking in debug mode)
250 #define MAX_SHIPS 150 // max number of ship instances there can be.
251 #define SHIPS_LIMIT 150 // what MAX_SHIPS will be at release time (for error checking in debug mode)
254 #define MAX_SHIPS 200 // max number of ship instances there can be.
255 #define SHIPS_LIMIT 200 // what MAX_SHIPS will be at release time (for error checking in debug mode)
258 #define HULL_DAMAGE_THRESHOLD_PERCENT 0.25f // Apply damage to hull, not shield if shield < this
259 #define HP_SCALE 1.2 // 1.2 means die when 20% of hits remaining
260 #define MAX_SHIP_HITS 8 // hits to kill a ship
261 #define MAX_SHIP_DETAIL_LEVELS 5 // maximum detail levels that a ship can render at
262 #define MAX_REINFORCEMENTS 10
264 #define MAX_ESCORT_SHIPS 3
265 #define MAX_SHIP_WEAPONS 5
266 #define MAX_OBJECT_STATUS 10
268 #define MAX_PRIMARY_WEAPON_TYPES 10
269 #define MAX_SECONDARY_WEAPON_TYPES 10
271 // defines for 'direction' parameter of ship_select_next_primary()
272 #define CYCLE_PRIMARY_NEXT 0
273 #define CYCLE_PRIMARY_PREV 1
285 #define TYPE_ATTACK_PROTECT 0
286 #define TYPE_REPAIR_REARM 1
288 #define MAX_REINFORCEMENT_MESSAGES 5
290 #define RF_IS_AVAILABLE (1<<0) // reinforcement is now available
293 char name[NAME_LENGTH]; // ship or wing name (ship and wing names don't collide)
294 int type; // what operations this reinforcement unit can perform
295 int uses; // number of times reinforcemnt unit can be used
296 int num_uses; // number of times this reinforcement was actually used
297 int arrival_delay; // how long after called does this reinforcement appear
299 char no_messages[MAX_REINFORCEMENT_MESSAGES][NAME_LENGTH]; // list of messages to possibly send when calling for reinforcement not available
300 char yes_messages[MAX_REINFORCEMENT_MESSAGES][NAME_LENGTH]; // list of messages to acknowledge reinforcement on the way
304 #define SW_FLAG_BEAM_FREE (1<<0) // if this is a beam weapon, its free to fire
305 #define SW_FLAG_TURRET_LOCK (1<<1) // is this turret is free to fire or locked
306 #define SW_FLAG_TAGGED_ONLY (1<<2) // only fire if target is tagged
309 int num_primary_banks; // Number of primary banks (same as model)
310 int num_secondary_banks; // Number of secondary banks (same as model)
312 int primary_bank_weapons[MAX_PRIMARY_BANKS]; // Weapon_info[] index for the weapon in the bank
313 int secondary_bank_weapons[MAX_SECONDARY_BANKS]; // Weapon_info[] index for the weapon in the bank
315 int current_primary_bank; // currently selected primary bank
316 int current_secondary_bank; // currently selected secondary bank
318 int next_primary_fire_stamp[MAX_PRIMARY_BANKS]; // next time this primary bank can fire
319 int next_secondary_fire_stamp[MAX_SECONDARY_BANKS]; // next time this secondary bank can fire
321 int secondary_bank_ammo[MAX_SECONDARY_BANKS]; // Number of missiles left in secondary bank
322 int secondary_bank_start_ammo[MAX_SECONDARY_BANKS]; // Number of missiles starting in secondary bank
323 int secondary_bank_capacity[MAX_SECONDARY_BANKS]; // Max number of missiles in bank
324 int secondary_next_slot[MAX_SECONDARY_BANKS]; // Next slot to fire in the bank
325 int secondary_bank_rearm_time[MAX_SECONDARY_BANKS]; // timestamp which indicates when bank can get new missile
327 int last_fired_weapon_index; // Index of last fired secondary weapon. Used for remote detonates.
328 int last_fired_weapon_signature; // Signature of last fired weapon.
329 int detonate_weapon_time; // time at which last fired weapon can be detonated
332 int flags; // see SW_FLAG_* defines above
336 // structure definition for a linked list of subsystems for a ship. Each subsystem has a pointer
337 // to the static data for the subsystem. The obj_subsystem data is defined and read in the model
338 // code. Other dynamic data (such as current_hits) should remain in this structure.
339 typedef struct ship_subsys {
340 struct ship_subsys *next, *prev; // Index of next and previous objects in list.
341 model_subsystem *system_info; // pointer to static data for this subsystem -- see model.h for definition
342 float current_hits; // current number of hits this subsystem has left.
345 vector turret_last_fire_direction; // direction pointing last time this turret fired
346 int turret_next_enemy_check_stamp; // time at which to next look for a new enemy.
347 int turret_next_fire_stamp; // next time this turret can fire
348 int turret_enemy_objnum; // object index of ship this turret is firing upon
349 int turret_enemy_sig; // signature of object ship this turret is firing upon
350 int turret_next_fire_pos; // counter which tells us which gun position to fire from next
351 float turret_time_enemy_in_range; // Number of seconds enemy in view cone, accuracy improves over time.
352 ship_subsys *targeted_subsys; // subsystem this turret is attacking
354 int turret_pick_big_attack_point_timestamp; // Next time to pick an attack point for this turret
355 vector turret_big_attack_point; // local coordinate of point for this turret to attack on enemy
357 // swarm (rapid fire) info
358 int turret_swarm_info_index;
361 float awacs_intensity;
366 // Data the renderer needs for ship instance specific data, like
367 // angles and if it is blown off or not.
368 // There are 2 of these because turrets need one for the turret and one for the barrel.
369 // Things like radar dishes would only use one.
370 submodel_instance_info submodel_info_1; // Instance data for main turret or main object
371 submodel_instance_info submodel_info_2; // Instance data for turret guns, if there is one
373 int disruption_timestamp; // time at which subsystem isn't disrupted
375 int subsys_cargo_name; // cap ship cargo on subsys
376 int subsys_cargo_revealed;
379 // structure for subsystems which tells us the total count of a particular type of subsystem (i.e.
380 // we might have 3 engines), and the relative strength of the subsystem. The #defines in model.h
381 // for SUBSYSTEM_xxx will be used as indices into this array.
382 typedef struct ship_subsys_info {
383 int num; // number of subsystems of type on this ship;
384 float total_hits; // total number of hits between all subsystems of this type.
385 float current_hits; // current count of hits for all subsystems of this type.
388 #define MAX_IFF_COLORS 7
390 #define IFF_COLOR_HOSTILE 0
391 #define IFF_COLOR_FRIENDLY 1
392 #define IFF_COLOR_NEUTRAL 2
393 #define IFF_COLOR_UNKNOWN 3
394 #define IFF_COLOR_SELECTION 4
395 #define IFF_COLOR_MESSAGE 5
396 #define IFF_COLOR_TAGGED 6
398 #define SET_COLOR_HOSTILE gr_set_color_fast(&IFF_colors[IFF_COLOR_HOSTILE][0])
399 #define SET_COLOR_FRIENDLY gr_set_color_fast(&IFF_colors[IFF_COLOR_FRIENDLY][0])
400 #define SET_COLOR_NEUTRAL gr_set_color_fast(&IFF_colors[IFF_COLOR_NEUTRAL][0])
401 #define SET_COLOR_UNKNOWN gr_set_color_fast(&IFF_colors[IFF_COLOR_UNKNOWN][0])
402 #define SET_COLOR_TAGGED gr_set_color_fast(&IFF_colors[IFF_COLOR_TAGGED][0])
404 // reference an array to store the different IFF colors
405 extern color IFF_colors[MAX_IFF_COLORS][2];
407 #include "ai.h" // ship_subsys must be declared before we include this.
408 #include "weapon.h" // ship_subsys must be declared before we include this.
410 //#define MAX_SHIP_SUBOBJECTS 50
412 //extern ship_subobj Ship_subsystems[MAX_SHIP_SUBOBJECTS];
414 // states for the flags variable within the ship structure
415 // low bits are for mission file savable flags..
416 // FRED needs these to be the low-order bits with no holes,
417 // because it indexes into an array, Hoffoss says.
418 #define SF_IGNORE_COUNT (1 << 0) // ignore this ship when counting ship types for goals
419 #define SF_REINFORCEMENT (1 << 1) // this ship is a reinforcement ship
420 #define SF_ESCORT (1 << 2) // this ship is an escort ship
421 #define SF_NO_ARRIVAL_MUSIC (1 << 3) // don't play arrival music when ship arrives
422 #define SF_NO_ARRIVAL_WARP (1 << 4) // no arrival warp in effect
423 #define SF_NO_DEPARTURE_WARP (1 << 5) // no departure warp in effect
424 #define SF_LOCKED (1 << 6) // can't manipulate ship in loadout screens
425 #define SF_INVULNERABLE (1 << 7)
427 // high bits are for internal flags not saved to mission files
428 // Go from bit 31 down to bit 3
429 #define SF_KILL_BEFORE_MISSION (1 << 31)
430 #define SF_DYING (1 << 30)
431 #define SF_DISABLED (1 << 29)
432 #define SF_DEPART_WARP (1 << 28) // ship is departing via warp-out
433 #define SF_DEPART_DOCKBAY (1 << 27) // ship is departing via docking bay
434 #define SF_ARRIVING_STAGE_1 (1 << 26) // ship is arriving. In other words, doing warp in effect, stage 1
435 #define SF_ARRIVING_STAGE_2 (1 << 25) // ship is arriving. In other words, doing warp in effect, stage 2
436 #define SF_ARRIVING (SF_ARRIVING_STAGE_1|SF_ARRIVING_STAGE_2)
437 #define SF_ENGINES_ON (1 << 24) // engines sound should play if set
438 #define SF_INITIALLY_DOCKED (1 << 23) // used by Fred to tell if this ship is initially docked with something else
439 #define SF_CARGO_REVEALED (1 << 22) // ship's cargo is revealed to all friendly ships
440 #define SF_FROM_PLAYER_WING (1 << 21) // set for ships that are members of any player starting wing
441 #define SF_PRIMARY_LINKED (1 << 20) // ships primary weapons are linked together
442 #define SF_SECONDARY_DUAL_FIRE (1 << 19) // ship is firing two missiles from the current secondary bank
443 #define SF_WARP_BROKEN (1 << 18) // set when warp drive is not working, but is repairable
444 #define SF_WARP_NEVER (1 << 17) // set when ship can never warp
445 #define SF_TRIGGER_DOWN (1 << 16) // ship has its "trigger" held down
446 #define SF_AMMO_COUNT_RECORDED (1 << 15) // we've recorded the inital secondary weapon count (which is used to limit support ship rearming)
447 #define SF_HIDDEN_FROM_SENSORS (1 << 14) // ship doesn't show up on sensors, blinks in/out on radar
448 #define SF_SCANNABLE (1 << 13) // ship is "scannable". Play scan effect and report as "Scanned" or "not scanned".
449 #define SF_WARPED_SUPPORT (1 << 12) // set when this is a support ship which was warped in automatically
450 #define SF_EXPLODED (1 << 11) // ship has exploded (needed for kill messages)
451 #define SF_SHIP_HAS_SCREAMED (1 << 10) // ship has let out a death scream
452 #define SF_RED_ALERT_STORE_STATUS (1 << 9) // ship status should be stored/restored if red alert mission
453 #define SF_VAPORIZE (1<<8) // ship is vaporized by beam - alternative death sequence
455 // MWA -- don't go below whatever bitfield is used for Fred above (currently 7)!!!!
457 #define SF_DEPARTING (SF_DEPART_WARP | SF_DEPART_DOCKBAY) // ship is departing
458 #define SF_CANNOT_WARP (SF_WARP_BROKEN | SF_WARP_NEVER | SF_DISABLED) // ship cannot warp out
460 #define MAX_DAMAGE_SLOTS 32
461 #define MAX_SHIP_ARCS 2 // How many "arcs" can be active at once... Must be less than MAX_ARC_EFFECTS in model.h.
462 #define NUM_SUB_EXPL_HANDLES 2 // How many different big ship sub explosion sounds can be played.
464 #define MAX_SHIP_CONTRAILS 6
466 typedef struct ship_spark {
467 vector pos; // position of spark in the submodel's RF
468 int submodel_num; // which submodel is making the spark
472 #define AWACS_WARN_NONE (1 << 0)
473 #define AWACS_WARN_25 (1 << 1)
474 #define AWACS_WARN_75 (1 << 2)
477 typedef struct ship {
479 int ai_index; // Index in Ai_info of ai_info associated with this ship.
480 int ship_info_index; // Index in ship_info for this ship
485 int respawn_priority;
487 // BEGIN PACK ubytes and chars
488 ubyte pre_death_explosion_happened; // If set, it means the 4 or 5 smaller explosions
492 // ship wing status info
493 char wing_status_wing_index; // wing index (0-4) in wingman status gauge
494 char wing_status_wing_pos; // wing position (0-5) in wingman status gauge
496 // alternate type name index
497 char alt_type_index; // only used for display purposes (read : safe)
499 // targeting laser info
500 char targeting_laser_bank; // -1 if not firing, index into polymodel gun points if it _is_ firing
501 // corkscrew missile stuff
502 ubyte num_corkscrew_to_fire; // # of corkscrew missiles lef to fire
504 // targeting laser info
505 int targeting_laser_objnum; // -1 if invalid, beam object # otherwise
506 // corkscrew missile stuff
507 int next_corkscrew_fire; // next time to fire a corkscrew missile
509 int final_death_time; // Time until big fireball starts
510 int really_final_death_time; // Time until ship breaks up and disappears
511 vector deathroll_rotvel; // Desired death rotational velocity
512 int dock_objnum_when_dead; // Objnum of ship docked to when ship died (-1 if none)
513 int final_warp_time; // pops when ship is completely warped out or warped in. Used for both warp in and out.
514 vector warp_effect_pos; // where the warp in effect comes in at
515 vector warp_effect_fvec; // The warp in effect's forward vector
519 int num_hits; // Note, this is the number of spark emitter positions!
520 ship_spark sparks[MAX_SHIP_HITS];
522 int special_exp_index;
524 char ship_name[NAME_LENGTH];
526 int team; // Which team it's on, HOSTILE, FRIENDLY, UNKNOWN, NEUTRAL
528 fix time_cargo_revealed; // time at which the cargo was revealed
530 int arrival_location;
531 int arrival_distance; // how far away this ship should arrive
532 int arrival_anchor; // name of object this ship arrives near (or in front of)
535 int departure_location; // depart to hyperspace or someplace else (like docking bay)
536 int departure_anchor; // when docking day -- index of ship to use
537 int departure_cue; // sexpression to eval when departing
538 int departure_delay; // time in seconds after sexp is true that we delay.
540 int wingnum; // wing number this ship is in. -1 if in no wing, Wing array index otherwise
541 int orders_accepted; // set of orders this ship will accept from the player.
543 // Subsystem fields. The subsys_list is a list of all subsystems (which might include multiple types
544 // of a particular subsystem, like engines). The subsys_info struct is information for particular
545 // types of subsystems. (i.e. the list might contain 3 engines. There will be one subsys_info entry
546 // describing the state of all engines combined) -- MWA 4/1/97
547 ship_subsys subsys_list; // linked list of subsystems for this ship.
548 ship_subsys *last_targeted_subobject[MAX_PLAYERS]; // Last subobject that has been targeted. NULL if none;(player specific)
549 ship_subsys_info subsys_info[SUBSYSTEM_MAX]; // info on particular generic types of subsystems
551 float *shield_integrity; // Integrity at each triangle in shield mesh.
554 int shield_recharge_index; // index into array holding the shield recharge rate
555 int weapon_recharge_index; // index into array holding the weapon recharge rate
556 int engine_recharge_index; // index into array holding the engine recharge rate
557 float weapon_energy; // Number of EUs in energy reserves
558 float current_max_speed; // Max ship speed (based on energy diverted to engines)
559 int next_manage_ets; // timestamp for when ai can next modify ets ( -1 means never )
561 uint flags; // flag variable to contain ship state (see SF_ #defines)
562 int reinforcement_index; // index into reinforcement struct or -1
564 float afterburner_fuel; // amount of afterburner fuel remaining (capacity is stored
565 // as afterburner_fuel_capacity in ship_info).
567 int cmeasure_count; // Number of charges of countermeasures this ship can hold.
568 int current_cmeasure; // Currently selected countermeasure.
570 int cmeasure_fire_stamp; // Time at which can fire countermeasure.
572 float target_shields_delta; // Target for shield recharge system.
573 float target_weapon_energy_delta; // Target for recharge system.
576 int shield_hits; // Number of hits on shield this frame.
578 float wash_intensity;
579 vector wash_rot_axis;
582 // store blast information about shockwaves that hit the ship
583 // ship_shockwave sw;
585 int num_swarm_missiles_to_fire; // number of swarm missiles that need to be launched
586 int next_swarm_fire; // timestamp of next swarm missile to fire
587 int next_swarm_path; // next path number for swarm missile to take
588 int num_turret_swarm_info; // number of turrets in process of launching swarm
590 int group; // group ship is in, or -1 if none. Fred thing
591 int death_roll_snd; // id of death roll sound, may need to be stopped early
592 int ship_list_index; // index of ship in Ship_objs[] array
594 int thruster_bitmap; // What frame the current thruster bitmap is at for this ship
595 float thruster_frame; // Used to keep track of which frame the animation should be on.
597 int thruster_glow_bitmap; // What frame the current thruster engine glow bitmap is at for this ship
598 float thruster_glow_frame; // Used to keep track of which frame the engine glow animation should be on.
599 float thruster_glow_noise; // Noise for current frame
601 int next_engine_stutter; // timestamp to time the engine stuttering when a ship dies
603 float total_damage_received; // total damage received (for scoring purposes)
604 float damage_ship[MAX_DAMAGE_SLOTS]; // damage applied from each player
605 int damage_ship_id[MAX_DAMAGE_SLOTS]; // signature of the damager (corresponds to each entry in damage_ship)
606 int persona_index; // which persona is this guy.
608 int subsys_disrupted_flags; // bitflags used to check if SUBYSTEM_* is disrupted or not
609 int subsys_disrupted_check_timestamp; // timer to control how oftern flags are set/cleared in subsys_disrupted_flags
611 uint create_time; // time ship was created, set by gettime()
613 // keep multiplayer specific stuff below this point
614 int ts_index; // index into the team select and Wss_slots array (or -1 if not in one of those arrays)
616 int large_ship_blowup_index; // -1 if not a large ship exploding, else this is an index used by the shipfx large ship exploding code.
617 int sub_expl_sound_handle[NUM_SUB_EXPL_HANDLES];
620 // Stuff for showing electrical arcs on damaged ships
621 vector arc_pts[MAX_SHIP_ARCS][2]; // The endpoints of each arc
622 int arc_timestamp[MAX_SHIP_ARCS]; // When this times out, the spark goes away. -1 is not used
623 ubyte arc_type[MAX_SHIP_ARCS]; // see MARC_TYPE_* defines in model.h
624 int arc_next_time; // When the next arc will be created.
627 float emp_intensity; // <= 0.0f if no emp effect present
628 float emp_decr; // how much to decrement EMP effect per second for this ship
631 short trail_num[MAX_SHIP_CONTRAILS];
634 float tag_total; // total tag time
635 float tag_left; // total tag remaining
636 fix time_first_tagged;
637 float level2_tag_total; // total tag time
638 float level2_tag_left; // total tag remaining
640 // old-style object update stuff
641 np_update np_updates[MAX_PLAYERS]; // for both server and client
643 // lightning timestamp
646 // AWACS warning flag
647 ubyte awacs_warning_flag;
649 // Special warpout objnum (warpout at knossos)
650 int special_warp_objnum;
653 // structure and array def for ships that have exited the game. Keeps track of certain useful
655 #define SEF_DESTROYED (1<<0)
656 #define SEF_DEPARTED (1<<1)
657 #define SEF_CARGO_KNOWN (1<<2)
658 #define SEF_PLAYER_DELETED (1<<3) // ship deleted by a player in ship select
659 #define SEF_BEEN_TAGGED (1<<4)
660 #define SEF_RED_ALERT_CARRY (1<<5)
662 #define MAX_EXITED_SHIPS 200
664 typedef struct exited_ship {
665 char ship_name[NAME_LENGTH];
673 extern exited_ship Ships_exited[MAX_EXITED_SHIPS];
675 // a couple of functions to get at the data
676 extern void ship_add_exited_ship( ship *shipp, int reason );
677 extern int ship_find_exited_ship_by_name( const char *name );
678 extern int ship_find_exited_ship_by_signature( int signature);
680 #define SIF_DO_COLLISION_CHECK (1 << 0)
681 #define SIF_PLAYER_SHIP (1 << 1)
682 #define SIF_DEFAULT_PLAYER_SHIP (1 << 2)
683 #define SIF_PATH_FIXUP (1 << 3) // when set, path verts have been set for this ship's model
684 #define SIF_SUPPORT (1 << 4) // this ship can perform repair/rearm functions
685 #define SIF_AFTERBURNER (1 << 5) // this ship has afterburners
687 // If you add a new ship type, then please add the appriopriate type in the ship_count
688 // structure later in this file!!! and let MWA know!!
689 #define SIF_CARGO (1 << 6) // is this ship a cargo type ship -- used for docking purposes
690 #define SIF_FIGHTER (1 << 7) // this ship is a fighter
691 #define SIF_BOMBER (1 << 8) // this ship is a bomber
692 #define SIF_CRUISER (1 << 9) // this ship is a cruiser
693 #define SIF_FREIGHTER (1 << 10) // this ship is a freighter
694 #define SIF_CAPITAL (1 << 11) // this ship is a capital/installation ship
695 #define SIF_TRANSPORT (1 << 12) // this ship is a transport
696 #define SIF_NAVBUOY (1 << 13) // AL 11-24-97: this is a navbuoy
697 #define SIF_SENTRYGUN (1 << 14) // AL 11-24-97: this is a navbuoy with turrets
698 #define SIF_ESCAPEPOD (1 << 15) // AL 12-09-97: escape pods that fire from big ships
699 #define SIF_NO_SHIP_TYPE (1 << 16) // made distinct to help trap errors
701 #define SIF_SHIP_COPY (1 << 17) // this ship is a copy of another ship in the table -- meaningful for scoring and possible other things
702 #define SIF_IN_TECH_DATABASE (1 << 18) // is ship type to be listed in the tech database?
703 #define SIF_IN_TECH_DATABASE_M (1 << 19) // is ship type to be listed in the tech database for multiplayer?
705 #define SIF_STEALTH (1 << 20) // the ship is a stealth ship
706 #define SIF_SUPERCAP (1 << 21) // the ship is a supercap
707 #define SIF_DRYDOCK (1 << 22) // the ship is a drydock
708 #define SIF_DONT_COLLIDE_INVIS (1 << 23) // Don't collide with this ship's invisible polygons
710 #define SIF_BIG_DAMAGE (1 << 24) // this ship is classified as a big damage ship
711 #define SIF_HAS_AWACS (1 << 25) // ship has an awacs subsystem
713 #define SIF_CORVETTE (1 << 26) // corvette class (currently this only means anything for briefing icons)
714 #define SIF_GAS_MINER (1 << 27) // also just for briefing icons
715 #define SIF_AWACS (1 << 28) // ditto
717 #define SIF_KNOSSOS_DEVICE (1 << 29) // this is the knossos device
719 #define SIF_NO_FRED (1 << 30) // not available in fred
721 #define MAX_SHIP_FLAGS 8 // Number of flags for flags field in ship_info struct
722 #define SIF_DEFAULT_VALUE (SIF_DO_COLLISION_CHECK)
723 #define SIF_ALL_SHIP_TYPES (SIF_CARGO | SIF_FIGHTER | SIF_BOMBER | SIF_CRUISER | SIF_FREIGHTER | SIF_CAPITAL | SIF_TRANSPORT | SIF_SUPPORT | SIF_NO_SHIP_TYPE | SIF_NAVBUOY | SIF_SENTRYGUN | SIF_ESCAPEPOD | SIF_SUPERCAP | SIF_CORVETTE | SIF_GAS_MINER | SIF_AWACS | SIF_KNOSSOS_DEVICE)
724 #define SIF_SMALL_SHIP (SIF_FIGHTER | SIF_BOMBER | SIF_SUPPORT | SIF_ESCAPEPOD )
725 #define SIF_BIG_SHIP (SIF_CRUISER | SIF_FREIGHTER | SIF_TRANSPORT | SIF_CORVETTE | SIF_GAS_MINER | SIF_AWACS)
726 #define SIF_HUGE_SHIP (SIF_CAPITAL | SIF_SUPERCAP | SIF_DRYDOCK | SIF_KNOSSOS_DEVICE)
727 #define SIF_NOT_FLYABLE (SIF_CARGO | SIF_NAVBUOY | SIF_SENTRYGUN) // AL 11-24-97: this useful to know for targeting reasons
728 #define SIF_HARMLESS (SIF_CARGO | SIF_NAVBUOY | SIF_ESCAPEPOD) // AL 12-3-97: ships that are not a threat
729 // for ships of this type, we make beam weapons miss a little bit otherwise they'd be way too powerful
730 #define SIF_BEAM_JITTER (SIF_CARGO | SIF_FIGHTER | SIF_BOMBER | SIF_FREIGHTER | SIF_TRANSPORT | SIF_SENTRYGUN | SIF_NAVBUOY | SIF_ESCAPEPOD)
732 // defines for ship types. These defines are distinct from the flag values in the ship_info struct. These
733 // values are used for array lookups, etc.
734 #define MAX_SHIP_TYPE_COUNTS 20
736 #define SHIP_TYPE_NONE 0
737 #define SHIP_TYPE_CARGO 1
738 #define SHIP_TYPE_FIGHTER_BOMBER 2
739 #define SHIP_TYPE_CRUISER 3
740 #define SHIP_TYPE_FREIGHTER 4
741 #define SHIP_TYPE_CAPITAL 5
742 #define SHIP_TYPE_TRANSPORT 6
743 #define SHIP_TYPE_REPAIR_REARM 7
744 #define SHIP_TYPE_NAVBUOY 8
745 #define SHIP_TYPE_SENTRYGUN 9
746 #define SHIP_TYPE_ESCAPEPOD 10
747 #define SHIP_TYPE_SUPERCAP 11
748 #define SHIP_TYPE_STEALTH 12
749 #define SHIP_TYPE_FIGHTER 13
750 #define SHIP_TYPE_BOMBER 14
751 #define SHIP_TYPE_DRYDOCK 15
752 #define SHIP_TYPE_AWACS 16
753 #define SHIP_TYPE_GAS_MINER 17
754 #define SHIP_TYPE_CORVETTE 18
755 #define SHIP_TYPE_KNOSSOS_DEVICE 19
757 // The real FreeSpace ship_info struct.
758 typedef struct ship_info {
759 char name[NAME_LENGTH]; // name for the ship
760 char short_name[NAME_LENGTH]; // short name, for use in the editor?
761 int species; // which species this craft belongs to
762 char *type_str; // type string used by tooltips
763 char *maneuverability_str; // string used by tooltips
764 char *armor_str; // string used by tooltips
765 char *manufacturer_str; // string used by tooltips
766 char *desc; // string used by tooltips
767 char *tech_desc; // string used by tech database
769 char *ship_length; // string used by multiplayer ship desc
770 char *gun_mounts; // string used by multiplayer ship desc
771 char *missile_banks; // string used by multiplayer ship desc
773 char pof_file[NAME_LENGTH]; // POF file to load/associate with ship
774 char pof_file_hud[NAME_LENGTH]; // POF file to load for the HUD target box
775 int num_detail_levels; // number of detail levels for this ship
776 int detail_distance[MAX_SHIP_DETAIL_LEVELS]; // distance to change detail levels at
777 int modelnum; // ship model
778 int modelnum_hud; // model to use when rendering to the HUD (eg, mini supercap)
779 float density; // density of the ship in g/cm^3 (water = 1)
781 float rotdamp; // rotational drag
782 vector max_vel; // max velocity of the ship in the linear directions -- read from ships.tbl
783 vector afterburner_max_vel; // max velocity of the ship in the linear directions when afterburners are engaged -- read from ships.tbl
784 vector max_rotvel; // maximum rotational velocity
785 vector rotation_time; // time to rotate in x/y/z dimension traveling at max rotvel
786 float srotation_time; // scalar, computed at runtime as (rotation_time.x + rotation_time.y)/2
787 float max_rear_vel; // max speed ship can go backwards.
789 float afterburner_forward_accel; // forward acceleration with afterburner engaged
793 int flags; // See SIF_xxxx
794 int ai_class; // Index into Ai_classes[]. Defined in ai.tbl
796 float max_speed, min_speed, max_accel;
798 // ship explosion info
799 float inner_rad; // radius within which maximum damage is applied
800 float outer_rad; // radius at which no damage is applied
801 float damage; // maximum damage applied from ship explosion
802 float blast; // maximum blast impulse from ship explosion
803 int explosion_propagates; // If true, then the explosion propagates
804 float shockwave_speed; // speed at which shockwave expands, 0 means no shockwave
805 int shockwave_count; // the # of total shockwaves
807 // subsystem information
808 int n_subsystems; // this number comes from ships.tbl
809 model_subsystem *subsystems; // see model.h for structure definition
811 // Energy Transfer System fields
812 float power_output; // power output of ships reactor (EU/s)
813 float max_overclocked_speed; // max speed when 100% power output sent to engines
814 float max_weapon_reserve; // maximum energy that can be stored for primary weapon usage
816 // Afterburner fields
817 float afterburner_fuel_capacity; // maximum afterburner fuel that can be stored
818 float afterburner_burn_rate; // rate in fuel/second that afterburner consumes fuel
819 float afterburner_recover_rate; // rate in fuel/second that afterburner recovers fuel
821 int cmeasure_max; // Number of charges of countermeasures this ship can hold.
823 int num_primary_banks; // Actual number of primary banks (property of model)
824 int num_secondary_banks; // Actual number of secondary banks (property of model)
825 int primary_bank_weapons[MAX_PRIMARY_BANKS]; // Weapon_info[] index for the weapon in the bank
826 int secondary_bank_weapons[MAX_SECONDARY_BANKS]; // Weapon_info[] index for the weapon in the bank
827 int secondary_bank_ammo_capacity[MAX_SECONDARY_BANKS]; // Capacity of bank (not number of missiles)
829 float initial_hull_strength; // Initial hull strength of this class of ship.
830 int engine_snd; // handle to engine sound for ship (-1 if no engine sound)
832 vector closeup_pos; // position for camera when using ship in closeup view (eg briefing and hud target monitor)
833 float closeup_zoom; // zoom when using ship in closeup view (eg briefing and hud target monitor)
835 int allowed_weapons[MAX_WEAPON_TYPES]; // array which specifies which weapons can be loaded out by the
836 // player during weapons loadout.
838 ubyte shield_icon_index; // index to locate ship-specific animation frames for the shield on HUD
839 char icon_filename[NAME_LENGTH]; // filename for icon that is displayed in ship selection
840 char anim_filename[NAME_LENGTH]; // filename for animation that plays in ship selection
841 char overhead_filename[NAME_LENGTH]; // filename for animation that plays weapons loadout
843 int score; // default score for this ship
845 int scan_time; // time to scan this ship (in ms)
848 trail_info ct_info[MAX_SHIP_CONTRAILS];
851 // rgb non-dimming pixels for this ship type
852 int num_nondark_colors;
853 ubyte nondark_colors[MAX_NONDARK_COLORS][3];
856 ubyte shield_color[3];
859 extern int num_wings;
860 extern ship Ships[MAX_SHIPS];
861 extern ship *Player_ship;
863 // Data structure to track the active missiles
864 typedef struct ship_obj {
865 ship_obj *next, *prev;
868 extern ship_obj Ship_obj_list;
870 typedef struct engine_wash_info
873 float angle; // half angle of cone around engine thruster
874 float radius_mult; // multiplier for radius
875 float length; // length of engine wash, measured from thruster
876 float intensity; // intensity of engine wash
879 #define MAX_ENGINE_WASH_TYPES 20
880 extern engine_wash_info Engine_wash_info[MAX_ENGINE_WASH_TYPES];
882 // ****************************************************************
883 // DO NOT CHANGE THIS - IT WILL LIKELY BREAK FREESPACE2 PXO SUPPORT
884 // TALK TO DAVE B FIRST
885 // ****************************************************************
886 #define MAX_SHIP_TYPES 130
888 #define MAX_SHIPS_PER_WING 6
890 #if defined(FS2_DEMO) || defined(FS1_DEMO)
896 #define MAX_PLAYER_WINGS 3 // number of wings player can start a mission with
898 // flags defined for wings
899 #define MAX_WING_FLAGS 8 // total number of flags in the wing structure -- used for parsing wing flags
900 #define WF_WING_GONE (1<<0) // all ships were either destroyed or departed
901 #define WF_WING_DEPARTING (1<<1) // wing's departure cue turned true
902 #define WF_IGNORE_COUNT (1<<2) // ignore all ships in this wing for goal counting purposes.
903 #define WF_REINFORCEMENT (1<<3) // is this wing a reinforcement wing
904 #define WF_RESET_REINFORCEMENT (1<<4) // needed when we need to reset the wing's reinforcement flag (after calling it in)
905 #define WF_NO_ARRIVAL_MUSIC (1<<5) // don't play arrival music when wing arrives
906 #define WF_EXPANDED (1<<6) // wing expanded in hotkey select screen
907 #define WF_NO_ARRIVAL_MESSAGE (1<<7) // don't play any arrival message
908 #define WF_NO_ARRIVAL_WARP (1<<8) // don't play warp effect for any arriving ships in this wing.
909 #define WF_NO_DEPARTURE_WARP (1<<9) // don't play warp effect for any departing ships in this wing.
910 #define WF_NO_DYNAMIC (1<<10) // members of this wing relentlessly pursue their ai goals
911 #define WF_DEPARTURE_ORDERED (1<<11) // departure of this wing was ordered by player
912 #define WF_NEVER_EXISTED (1<<12) // this wing never existed because something prevented it from being created (like its mother ship being destroyed)
914 // Defines a wing of ships.
915 typedef struct wing {
916 char name[NAME_LENGTH];
917 int reinforcement_index; // index in reinforcement struct or -1
920 int num_waves, current_wave; // members for dealing with waves
921 int threshold; // when number of ships in the wing reaches this number -- new wave
923 fix time_gone; // time into the mission when this wing is officiall gone.
925 int wave_count; // max ships per wave (as defined by the number of ships in the ships list)
926 int total_arrived_count; // count of number of ships that we have created, regardless of wave
927 int current_count; // count of number of ships actually in this wing -- used for limit in next array
928 int ship_index[MAX_SHIPS_PER_WING]; // index into ships array of all ships currently in the wing
930 int total_destroyed; // total number of ships destroyed in the wing (including all waves)
931 int total_departed; // total number of ships departed in this wing (including all waves)
933 int special_ship; // the leader of the wing. An index into ship_index[].
935 int arrival_location; // arrival and departure information for wings -- similar to info for ships
936 int arrival_distance; // distance from some ship where this ship arrives
937 int arrival_anchor; // name of object this ship arrives near (or in front of)
941 int departure_location;
942 int departure_anchor; // name of object that we depart to (in case of dock bays)
946 int wave_delay_min; // minimum number of seconds before new wave can arrive
947 int wave_delay_max; // maximum number of seconds before new wave can arrive
948 int wave_delay_timestamp; // timestamp used for delaying arrival of next wave
952 ai_goal ai_goals[MAX_AI_GOALS]; // goals for the wing -- converted to ai_goal struct
954 ushort net_signature; // starting net signature for ships in this wing. assiged at mission load time
958 #define STARTING_WING_ALPHA 0
959 #define STARTING_WING_BETA 1
960 #define STARTING_WING_GAMMA 2
961 #define STARTING_WING_ZETA 3
963 extern wing Wings[MAX_WINGS];
964 extern int Starting_wings[MAX_PLAYER_WINGS];
965 extern int ai_paused;
967 extern int Num_reinforcements;
968 extern int Num_ship_types;
969 extern ship_info Ship_info[MAX_SHIP_TYPES];
970 extern reinforcements Reinforcements[MAX_REINFORCEMENTS];
972 // structure definition for ship type counts. Used to give a count of the number of ships
973 // of a particular type, and the number of times that a ship of that particular type has been
974 // killed. When changing any info here, be sure to update the ship_type_names array in Ship.cpp
975 // the order of the types here MUST match the order of the types in the array
976 typedef struct ship_counts {
981 extern const char *Ship_type_names[MAX_SHIP_TYPE_COUNTS];
982 extern int Ship_type_flags[MAX_SHIP_TYPE_COUNTS]; // SIF_* flags for each ship type
983 extern ship_counts Ship_counts[MAX_SHIP_TYPE_COUNTS];
986 // Use the below macros when you want to find the index of an array element in the
987 // Wings[] or Ships[] arrays.
988 #define WING_INDEX(wingp) (wingp-Wings)
989 #define SHIP_INDEX(shipp) (shipp-Ships)
992 extern void ship_init(); // called once at game start
993 extern void ship_level_init(); // called before the start of each level
995 //returns -1 if failed
996 extern int ship_create(matrix * orient, vector * pos, int ship_type);
997 extern void change_ship_type(int n, int ship_type);
998 extern void ship_model_change(int n, int ship_type);
999 extern void ship_process_pre( object * objp, float frametime );
1000 extern void ship_process_post( object * objp, float frametime );
1001 extern void ship_render( object * objp );
1002 extern void ship_delete( object * objp );
1003 extern int ship_check_collision_fast( object * obj, object * other_obj, vector * hitpos );
1004 extern int ship_get_num_ships();
1006 extern int ship_fire_primary_debug(object *objp); // Fire the debug laser.
1007 extern int ship_fire_primary(object * objp, int stream_weapons, int force = 0);
1008 extern int ship_fire_secondary(object * objp, int allow_swarm = 0 );
1009 extern int ship_launch_countermeasure(object *objp, int rand_val = -1);
1011 // for special targeting lasers
1012 extern void ship_start_targeting_laser(ship *shipp);
1013 extern void ship_stop_targeting_laser(ship *shipp);
1014 extern void ship_process_targeting_lasers();
1016 extern int ship_select_next_primary(object *objp, int direction);
1017 extern int ship_select_next_secondary(object *objp);
1018 extern int get_available_secondary_weapons(object *objp, int *outlist, int *outbanklist);
1019 extern void ship_recalc_subsys_strength( ship *shipp );
1020 extern void subsys_set(int objnum, int ignore_subsys_info = 0);
1021 extern void physics_ship_init(object *objp);
1023 // Note: This is not a general purpose routine.
1024 // It is specifically used for targeting.
1025 // It only returns a subsystem position if it has shields.
1026 // Return true/false for subsystem found/not found.
1027 // Stuff vector *pos with absolute position.
1028 extern int get_subsystem_pos(vector *pos, object *objp, ship_subsys *subsysp);
1030 extern int ship_info_lookup(const char *name);
1031 extern int ship_info_base_lookup(const int si_index);
1032 extern int ship_name_lookup(const char *name, int inc_players = 0); // returns the index into Ship array of name
1033 extern int ship_type_name_lookup(const char *name);
1035 extern int wing_lookup(const char *name);
1037 // returns 0 if no conflict, 1 if conflict, -1 on some kind of error with wing struct
1038 extern int wing_has_conflicting_teams(int wing_index);
1040 // next function takes optional second parameter which says to ignore the current count of ships
1041 // in the wing -- used to tell is the wing exists or not, not whether it exists and has ships currently
1043 extern int wing_name_lookup(const char *name, int ignore_count = 0);
1045 extern int Player_ship_class;
1047 #define MAX_PLAYER_SHIP_CHOICES 15
1048 extern int Num_player_ship_precedence; // Number of ship types in Player_ship_precedence
1049 extern int Player_ship_precedence[MAX_PLAYER_SHIP_CHOICES]; // Array of ship types, precedence list for player ship/wing selection
1052 // Do the special effect for energy dissipating into the shield for a hit.
1053 // model_num = index in Polygon_models[]
1054 // centerp = pos of object, sort of the center of the shield
1055 // tcp = hit point, probably the global hit_point set in polygon_check_face
1056 // tr0 = index of polygon in shield pointer in polymodel.
1057 extern void create_shield_explosion(int objnum, int model_num, matrix *orient, vector *centerp, vector *tcp, int tr0);
1059 // Initialize shield hit system.
1060 extern void shield_hit_init();
1061 extern void create_shield_explosion_all(object *objp);
1062 extern void shield_frame_init();
1063 extern void add_shield_point(int objnum, int tri_num, vector *hit_pos);
1064 extern void add_shield_point_multi(int objnum, int tri_num, vector *hit_pos);
1065 extern void shield_point_multi_setup();
1066 extern void shield_hit_close();
1068 void ship_draw_shield( object *objp);
1070 float apply_damage_to_shield(object *objp, int shield_quadrant, float damage);
1071 float compute_shield_strength(object *objp);
1073 // Returns true if the shield presents any opposition to something
1074 // trying to force through it.
1075 // If quadrant is -1, looks at entire shield, otherwise
1076 // just one quadrant
1077 int ship_is_shield_up( object *obj, int quadrant );
1079 //=================================================
1080 // These two functions transfer instance specific angle
1081 // data into and out of the model structure, which contains
1082 // angles, but not for each instance of model being used. See
1083 // the actual functions in ship.cpp for more details.
1084 extern void ship_model_start(object *objp);
1085 extern void ship_model_stop(object *objp);
1087 //============================================
1088 extern int ship_find_num_crewpoints(object *objp);
1089 extern int ship_find_num_turrets(object *objp);
1091 extern void ship_get_eye( vector *eye_pos, matrix *eye_orient, object *obj ); // returns in eye the correct viewing position for the given object
1092 extern ship_subsys *ship_get_indexed_subsys( ship *sp, int index, vector *attacker_pos = NULL ); // returns index'th subsystem of this ship
1093 extern int ship_get_index_from_subsys(ship_subsys *ssp, int objnum, int error_bypass = 0);
1094 extern int ship_get_subsys_index(ship *sp, char *ss_name, int error_bypass = 0); // returns numerical index in linked list of subsystems
1095 extern float ship_get_subsystem_strength( ship *shipp, int type );
1096 extern ship_subsys *ship_get_subsys(ship *shipp, char *subsys_name);
1098 // subsys disruption
1099 extern int ship_subsys_disrupted(ship_subsys *ss);
1100 extern int ship_subsys_disrupted(ship *sp, int type);
1101 extern void ship_subsys_set_disrupted(ship_subsys *ss, int time);
1103 extern int ship_do_rearm_frame( object *objp, float frametime );
1104 extern void ship_wing_cleanup( int shipnum, wing *wingp );
1106 extern object *ship_find_repair_ship( object *requester );
1107 extern void ship_close(); // called in game_shutdown() to free malloced memory
1110 extern void ship_assign_sound_all();
1111 extern void ship_assign_sound(ship *sp);
1113 extern void ship_add_ship_type_count( int ship_info_flag, int num );
1114 extern void ship_add_ship_type_kill_count( int ship_info_flag );
1117 extern int ship_get_default_orders_accepted( ship_info *sip );
1118 extern int ship_query_general_type(int ship);
1119 extern int ship_query_general_type(ship *shipp);
1120 extern int ship_docking_valid(int docker, int dockee);
1121 extern int get_quadrant(vector *hit_pnt); // Return quadrant num of last hit ponit.
1123 extern void ship_obj_list_rebuild(); // only called by save/restore code
1124 extern int ship_query_state(char *name);
1126 int ship_secondary_bank_has_ammo(int shipnum); // check if current secondary bank has ammo
1128 void ship_departed( int num );
1129 int ship_can_warp(ship *sp); // check if ship has engine power to warp
1130 int ship_return_subsys_path_normal(ship *sp, ship_subsys *ss, vector *gsubpos, vector *norm);
1131 int ship_subsystem_in_sight(object* objp, ship_subsys* subsys, vector *eye_pos, vector* subsys_pos, int do_facing_check=1, float *dot_out=NULL, vector *vec_out=NULL);
1132 ship_subsys *ship_return_next_subsys(ship *shipp, int type, vector *attacker_pos);
1134 // defines and definition for function to get a random ship of a particular team (any ship,
1135 // any ship but player ships, or only players)
1136 #define SHIP_GET_ANY_SHIP 0
1137 #define SHIP_GET_NO_PLAYERS 1
1138 #define SHIP_GET_ONLY_PLAYERS 2
1140 extern int ship_get_random_team_ship( int team, int flags = SHIP_GET_ANY_SHIP, float max_dist=0.0f );
1141 extern int ship_get_random_player_wing_ship( int flags = SHIP_GET_ANY_SHIP, float max_dist=0.0f, int persona_index = -1, int get_first=0, int multi_team = -1 );
1142 extern int ship_get_random_ship_in_wing(int wingnum, int flags = SHIP_GET_ANY_SHIP, float max_dist=0.0f, int get_first=0 );
1144 // return ship index
1145 int ship_get_random_ship();
1147 extern int ship_get_by_signature(int signature);
1150 extern int Ai_render_debug_flag;
1151 extern int Show_shield_mesh, New_shield_system;
1152 extern int Ship_auto_repair; // flag to indicate auto-repair of subsystem should occur
1155 void ship_subsystem_delete(ship *shipp);
1156 void ship_set_default_weapons(ship *shipp, ship_info *sip);
1157 float ship_quadrant_shield_strength(object *hit_objp, vector *hitpos);
1159 int ship_dumbfire_threat(ship *sp);
1160 int ship_lock_threat(ship *sp);
1162 int bitmask_2_bitnum(int num);
1163 char *ship_return_orders(char *outbuf, ship *sp);
1164 char *ship_return_time_to_goal(char *outbuf, ship *sp);
1165 void ship_check_cargo_all(); // called from game_simulation_frame
1167 void ship_maybe_warn_player(ship *enemy_sp, float dist);
1168 void ship_maybe_praise_player(ship *deader_sp);
1169 void ship_maybe_ask_for_help(ship *sp);
1170 void ship_scream(ship *sp);
1171 void ship_maybe_scream(ship *sp);
1172 void ship_maybe_tell_about_rearm(ship *sp);
1173 void ship_maybe_lament();
1175 void ship_primary_changed(ship *sp);
1176 void ship_secondary_changed(ship *sp);
1178 // get the Ship_info flags for a given ship
1179 int ship_get_SIF(ship *shipp);
1180 int ship_get_SIF(int sh);
1181 extern void ship_do_cargo_revealed( ship *shipp, int from_network = 0 );
1183 float ship_get_secondary_weapon_range(ship *shipp);
1184 int get_max_ammo_count_for_bank(int ship_class, int bank, int ammo_type);
1186 int is_support_allowed(object *objp);
1188 // Given an object and a turret on that object, return the actual firing point of the gun
1189 // and its normal. This uses the current turret angles. We are keeping track of which
1190 // gun to fire next in the ship specific info for this turret subobject. Use this info
1191 // to determine which position to fire from next.
1193 // *gpos: absolute position of gun firing point
1194 // *gvec: vector fro *gpos to *targetp
1195 void ship_get_global_turret_gun_info(object *objp, ship_subsys *ssp, vector *gpos, vector *gvec, int use_angles, vector *targetp);
1197 // Given an object and a turret on that object, return the global position and forward vector
1198 // of the turret. The gun normal is the unrotated gun normal, (the center of the FOV cone), not
1199 // the actual gun normal given using the current turret heading. But it _is_ rotated into the model's orientation
1201 void ship_get_global_turret_info(object *objp, model_subsystem *tp, vector *gpos, vector *gvec);
1203 // return 1 if objp is in fov of the specified turret, tp. Otherwise return 0.
1204 // dist = distance from turret to center point of object
1205 int object_in_turret_fov(object *objp, model_subsystem *tp, vector *tvec, vector *tpos, float dist);
1207 // forcible jettison cargo from a ship
1208 void ship_jettison_cargo(ship *shipp);
1210 // get damage done by exploding ship, takes into account mods for individual ship
1211 float ship_get_exp_damage(object* objp);
1213 // get whether ship has shockwave, takes into account mods for individual ship
1214 int ship_get_exp_propagates(ship *sp);
1216 // get outer radius of damage, takes into account mods for individual ship
1217 float ship_get_exp_outer_rad(object *ship_objp);
1219 // returns whether subsys is allowed to have cargo
1220 int valid_cap_subsys_cargo_list(char *subsys_name);
1222 // determine turret status of a given subsystem, returns 0 for no turret, 1 for "fixed turret", 2 for "rotating" turret
1223 int ship_get_turret_type(ship_subsys *subsys);
1225 // get ship by object signature, returns OBJECT INDEX
1226 int ship_get_by_signature(int sig);
1228 // get the team of a reinforcement item
1229 int ship_get_reinforcement_team(int r_index);
1231 // determine if the given texture is used by a ship type. return ship info index, or -1 if not used by a ship
1232 int ship_get_texture(int bitmap);
1234 // update artillery lock info
1235 void ship_update_artillery_lock();
1237 // checks if a world point is inside the extended bounding box of a ship
1238 int check_world_pt_in_expanded_ship_bbox(vector *world_pt, object *objp, float delta_box);
1240 // returns true if objp is ship and is tagged
1241 int ship_is_tagged(object *objp);
1243 // returns max normal speed of ship (overclocked / afterburned)
1244 float ship_get_max_speed(ship *shipp);
1246 // returns warp speed of ship
1247 float ship_get_warp_speed(object *objp);
1249 // returns true if ship is beginning to speed up in warpout
1250 int ship_is_beginning_warpout_speedup(object *objp);
1252 // given a ship info type, return a species
1253 int ship_get_species_by_type(int ship_info_index);
1255 // return the length of the ship
1256 float ship_get_length(ship* shipp);