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