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/ShipHit.h $
15 * Code to deal with a ship getting hit by something, be it a missile, dog, or ship.
18 * Revision 1.2 2002/06/09 04:41:15 relnev
19 * added copyright header
21 * Revision 1.1.1.1 2002/05/03 03:28:12 root
25 * 9 8/22/99 5:53p Dave
26 * Scoring fixes. Added self destruct key. Put callsigns in the logfile
27 * instead of ship designations for multiplayer players.
29 * 8 6/21/99 7:25p Dave
30 * netplayer pain packet. Added type E unmoving beams.
32 * 7 5/11/99 10:16p Andsager
33 * First pass on engine wash effect. Rotation (control input), damage,
36 * 6 4/20/99 3:43p Andsager
37 * Added normal parameter to ship_apply_local_damage for case of ship_ship
40 * 5 2/04/99 1:23p Andsager
41 * Apply max spark limit to ships created in mission parse
43 * 4 10/20/98 1:39p Andsager
44 * Make so sparks follow animated ship submodels. Modify
45 * ship_weapon_do_hit_stuff() and ship_apply_local_damage() to add
46 * submodel_num. Add submodel_num to multiplayer hit packet.
48 * 3 10/16/98 1:22p Andsager
49 * clean up header files
51 * 2 10/07/98 10:53a Dave
54 * 1 10/07/98 10:51a Dave
56 * 8 5/18/98 12:41a Allender
57 * fixed subsystem problems on clients (i.e. not reporting properly on
58 * damage indicator). Fixed ingame join problem with respawns. minor
61 * 7 4/24/98 5:35p Andsager
62 * Fix sparks sometimes drawing not on model. If ship is sphere in
63 * collision, don't draw sparks. Modify ship_apply_local_damage() to take
66 * 6 4/09/98 5:44p Allender
67 * multiplayer network object fixes. debris and self destructed ships
68 * should all sync up. Fix problem where debris pieces (hull pieces) were
69 * not getting a net signature
71 * 5 2/13/98 2:22p Allender
72 * make ships spark when entering mission with < 100% hull
74 * 4 10/16/97 4:41p Allender
75 * new packet to tell clients when subsystem has been destroyed
77 * 3 9/18/97 4:08p John
78 * Cleaned up & restructured ship damage stuff.
80 * 2 9/17/97 5:12p John
81 * Restructured collision routines. Probably broke a lot of stuff.
83 * 1 9/17/97 3:42p John
96 #define CREATE_SPARKS 1
98 #define MISS_SHIELDS -1
100 // ===================== NOTE!! =========================
101 // To apply damage to a ship, call either ship_apply_local_damage or ship_apply_global_damage.
102 // These replace the old calls to ship_hit and ship_do_damage...
103 // These functions do nothing to the ship's physics; that is the responsibility
104 // of whoever is calling these functions. These functions are strictly
105 // for damaging ship's hulls, shields, and subsystems. Nothing more.
107 // function to destroy a subsystem. Called internally and from multiplayer messaging code
108 extern void do_subobj_destroyed_stuff( ship *ship_p, ship_subsys *subsys, vector *hitpos );
111 // This gets called to apply damage when something hits a particular point on a ship.
112 // This assumes that whoever called this knows if the shield got hit or not.
113 // hitpos is in world coordinates.
114 // if shield_quadrant is not -1, then that part of the shield takes damage properly.
115 void ship_apply_local_damage(object *ship_obj, object *other_obj, vector *hitpos, float damage, int shield_quadrant, bool create_spark=true, int submodel_num=-1, vector *hit_normal=NULL);
117 // This gets called to apply damage when a damaging force hits a ship, but at no
118 // point in particular. Like from a shockwave. This routine will see if the
119 // shield got hit and if so, apply damage to it.
120 // You can pass force_center==NULL if you the damage doesn't come from anywhere,
121 // like for debug keys to damage an object or something. It will
122 // assume damage is non-directional and will apply it correctly.
123 void ship_apply_global_damage(object *ship_obj, object *other_obj, vector *force_center, float damage );
125 // like above, but does not apply damage to shields
126 void ship_apply_wash_damage(object *ship_obj, object *other_obj, float damage);
128 // next routine needed for multiplayer
129 void ship_hit_kill( object *ship_obj, object *other_obj, float percent_killed, int self_destruct);
131 void ship_self_destruct( object *objp );
133 // Call this instead of physics_apply_whack directly to
134 // deal with two ships docking properly.
135 void ship_apply_whack(vector *force, vector *new_pos, object *objp);
137 // externed for code in missionparse to create sparks on a ship with < 100% hull integrity.
138 void ship_hit_sparks_no_rotate(object *ship_obj, vector *hitpos);
140 // externed so that ships which self destruct have the proper things done to them in multiplayer
141 void ship_generic_kill_stuff( object *objp, float percent_killed );
143 // find the max number of sparks allowed for ship
144 // limited for fighter by hull % others by radius.
145 int get_max_sparks(object* ship_obj);
148 void ship_hit_pain(float damage);