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