/
mobj.h
223 lines (200 loc) · 7.96 KB
/
mobj.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/** @file mobj.h Common playsim map object (mobj) functionality.
*
* @authors Copyright © 2003-2013 Jaakko Keränen <jaakko.keranen@iki.fi>
* @authors Copyright © 2006-2015 Daniel Swanson <danij@dengine.net>
* @authors Copyright © 1993-1996 id Software, Inc.
*
* @par License
* GPL: http://www.gnu.org/licenses/gpl.html
*
* <small>This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. This program is distributed in the hope that it
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details. You should have received a copy of the GNU
* General Public License along with this program; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA</small>
*/
#ifndef LIBCOMMON_MOBJ_H
#define LIBCOMMON_MOBJ_H
#include "common.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* Determines the current friction affecting @a mo, given the sector it is in and
* whether it is on the floor.
*
* @param mob Map-object instance.
*
* @return Friction factor to apply to the momentum.
*/
coord_t Mobj_Friction(mobj_t const *mob);
/**
* Calculates the thrust multiplier for the mobj, to be applied when the mobj momentum
* changes under thrust. The multiplier adjusts thrust behavior to account for slippery
* or sticky surfaces.
*
* @param mob Map-object instance.
*
* @return Thrust multiplier.
*/
coord_t Mobj_ThrustMul(mobj_t const *mob);
/**
* Calculates the mobj thrust multiplier given a certain friction. The thrust multiplier
* counters the effect of increased friction to retain normal thrust behavior.
*
* @param friction Friction factor.
*
* @return Thrust factor to account for amount of friction.
*/
coord_t Mobj_ThrustMulForFriction(coord_t friction);
/**
* Handles the stopping of mobj movement. Also stops player walking animation.
*
* @param mob Map-object instance.
*/
void Mobj_XYMoveStopping(mobj_t *mob);
/**
* Checks if @a thing is a clmobj of one of the players.
*
* @param mob Map-object instance.
*/
dd_bool Mobj_IsPlayerClMobj(mobj_t *mob);
/**
* Determines if a mobj is a player mobj. It could still be a voodoo doll, also.
*
* @param mob Map-object instance.
*
* @return @c true iff the mobj is a player.
*/
dd_bool Mobj_IsPlayer(mobj_t const *mob);
/**
* Determines if a map-object is a voodoo doll.
*
* @param mob Map-object instance.
*
* @return @c true if the map-object is a voodoo doll.
*/
dd_bool Mobj_IsVoodooDoll(mobj_t const *mob);
/**
* Determines if the map-object is currently in mid air (i.e., not touching the floor
* or, stood on some other object).
*
* @param mob Map-object instance.
*
* @return @c true if the map-object is considered to be airborne/flying.
*/
dd_bool Mobj_IsAirborne(mobj_t const *mob);
/**
* Determines the world space angle between @em this map-object and the given @a point.
*
* @param mob Map-object instance.
* @param point World space point being aimed at.
* @param pointShadowed @c true= @a point is considered "shadowed", meaning that
* the final angle should include some random variance to
* simulate inaccuracy (e.g., the partial-invisibility sphere
* in DOOM makes the player harder to aim at).
*
* @return The final angle of aim.
*/
angle_t Mobj_AimAtPoint2(mobj_t *mob, coord_t const point[3], dd_bool pointShadowed);
angle_t Mobj_AimAtPoint (mobj_t *mob, coord_t const point[3]/*, dd_bool pointShadowed = false*/);
/**
* Behavior akin to @ref Mobj_AimAtPoint() however the parameters of the point to
* be aimed at is taken from the currently targeted map-object. If no map-object
* is presently targeted then @em this map-object's own angle is returned instead
* (i.e., aim in the direction currently faced).
*
* @param mob Map-object instance.
*
* @return The final angle of aim.
*/
angle_t Mobj_AimAtTarget(mobj_t *mob);
/**
* @param mob Map-object instance.
* @param allAround @c false= only look 180 degrees in front.
*
* @return @c true iff a player was targeted.
*/
dd_bool Mobj_LookForPlayers(mobj_t *mob, dd_bool allAround);
/**
* @param mob Map-object instance.
* @param stateNum Unique identifier of the state to change to.
*
* @return @c true if the mobj is still present.
*/
dd_bool P_MobjChangeState(mobj_t *mob, statenum_t stateNum);
/**
* Same as P_MobjChangeState but does not call action functions.
*
* @param mob Map-object instance.
* @param stateNum Unique identifier of the state to change to.
*
* @return @c true if the mobj is still present.
*/
dd_bool P_MobjChangeStateNoAction(mobj_t *mob, statenum_t stateNum);
/**
* Check whether the mobj is currently obstructed and explode immediately if so.
*
* @return Pointer to @em this mobj iff it survived, otherwise @c nullptr.
*/
mobj_t *Mobj_ExplodeIfObstructed(mobj_t *mob);
/**
* Launch the given map-object @a missile (if any) at the specified @a angle.
*
* @param missile Map-object to be launched.
* @param angle World space angle at which to launch.
* @param targetPos World space point being targeted (for determining speed).
* @param sourcePos World space point to use as the source (for determining
* speed). Can be @c nullptr in which case the origin coords
* of @a missile are used instead.
* @param extraMomZ Additional momentum to apply to the missile.
*
* @return Same as @a missile, for caller convenience.
*/
mobj_t *P_LaunchMissile(mobj_t *missile, angle_t angle, coord_t const targetPos[3],
coord_t const sourcePos[3], coord_t extraMomZ);
/**
* Launch the given map-object @a missile (if any) at the specified @a angle,
* enqueuing a new launch sound and recording @em this map-object as the source.
*
* @param mob Map-object hurler of @a missile.
* @param missile Map-object to be launched.
* @param angle World space angle at which to launch.
* @param targetPos World space point being targeted (for determining speed).
* @param sourcePos World space point to use as the source (for determining
* speed). Can be @c nullptr in which case the origin coords
* of @a missile are used instead.
* @param extraMomZ Additional momentum to apply to the missile.
*
* @return Same as @a missile, for caller convenience.
*
* @see P_LaunchMissile()
*/
mobj_t *Mobj_LaunchMissileAtAngle2(mobj_t *mob, mobj_t *missile, angle_t angle, coord_t const targetPos[3], coord_t const sourcePos[3], coord_t extraMomZ);
mobj_t *Mobj_LaunchMissileAtAngle (mobj_t *mob, mobj_t *missile, angle_t angle, coord_t const targetPos[3], coord_t const sourcePos[3]/*, coord_t extraMomZ = 0*/);
/**
* Same as @ref Mobj_LaunchMissileAtAngle() except the angle is that which the
* @a missile is presently facing.
*
* @param mob Map-object hurler of @a missile.
* @param missile Map-object to be launched.
* @param targetPos World space point being targeted (for determining speed).
* @param sourcePos World space point to use as the source (for determining
* speed). Can be @c nullptr in which case the origin coords
* of @a missile are used instead.
* @param extraMomZ Additional momentum to apply to the missile.
*
* @return Same as @a missile, for caller convenience.
*/
mobj_t *Mobj_LaunchMissile2(mobj_t *mob, mobj_t *missile, coord_t const targetPos[3], coord_t const sourcePos[3], coord_t extraMomZ);
mobj_t *Mobj_LaunchMissile (mobj_t *mob, mobj_t *missile, coord_t const targetPos[3], coord_t const sourcePos[3]/*, coord_t extraMomZ = 0*/);
void Mobj_InflictDamage(mobj_t *mob, mobj_t const *inflictor, int damage);
#ifdef __cplusplus
} // extern "C"
#endif
#endif // LIBCOMMON_MOBJ_H