Debian Codegraph @

Descent3/osiris_predefs.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/main/osiris_predefs.h $
21 * $Revision: 47 $
22 * $Date: 5/05/99 4:56p $
23 * $Author: Chris $
24 *
25 * Header file for osiris predefined functions
26 *
27 * $Log: /DescentIII/main/osiris_predefs.h $
28 *
29 * 47 5/05/99 4:56p Chris
30 * Added the RType powerup for the GB
31 *
32 * 46 4/29/99 7:15p Jeff
33 * added initial velocity parameter to Obj_Create
34 *
35 * 45 4/24/99 2:19a Chris
36 * Added another parameter to FollowPathSimple
37 *
38 * 44 4/24/99 12:09a Jeff
39 * added path value functions
40 *
41 * 43 4/20/99 8:56p Chris
42 * Fixed problem with robots not being able to open locked doors that a
43 * player has the key for.
44 *
45 * 42 4/14/99 3:57a Jeff
46 * fixed case mismatch in #includes
47 *
48 * 41 4/02/99 10:18a Chris
49 * We can now mess with the Object_info anim stuff
50 *
51 * 40 3/17/99 11:47a Jeff
52 * exported function to get what language we are using
53 *
54 * 39 3/03/99 3:01a Chris
55 * Exported the difficulty stuff to OSIRIS
56 *
57 * 38 3/03/99 12:11a Chris
58 * one more AI path check function
59 *
60 * 37 3/03/99 12:07a Chris
61 * Added the two new OSIRIS predefs for AI path finding
62 *
63 * 36 3/01/99 7:20p Chris
64 * Fixed dist problems with finding nearby objects
65 *
66 * 35 2/28/99 11:30p Chris
67 * FindObjOfType and OSIRIS controllable deaths
68 *
69 * 34 2/22/99 8:22p Chris
70 *
71 * 33 2/22/99 8:17p Chris
72 * Added the LGoal_Value() function to OSIRIS
73 *
74 * 32 2/21/99 5:51p Chris
75 * FIxed a bug with OBJV_C_TYPE (It should have been OBJV_I_TYPE). Added
76 * Obj_FindType()
77 *
78 * 31 2/18/99 4:28p Jeff
79 * added lookup functions for matcen, paths, level goals
80 *
81 * 30 2/11/99 2:56a Jeff
82 * improvements to introcam
83 *
84 * 29 2/10/99 1:47p Matt
85 * Changed object handle symbolic constants
86 *
87 * 28 2/08/99 3:06a Jeff
88 * created a function to switch a player between ai and flying control
89 * types (not exported to osiris...instead used in multisafe)
90 *
91 * 26 2/03/99 12:43a Chris
92 * Added Obj_GetGroundPos
93 *
94 * 25 1/29/99 5:10p Chris
95 * Added an optional parent handle check for FindObjOfType
96 *
97 * 24 1/25/99 8:38a Chris
98 * The the GUID to AI_FollowPathSimple
99 *
100 * 23 1/25/99 7:43a Chris
101 * Added the GUID (Goal Unique Id) and added the ability for weapon
102 * batteries to always fire exactly forward.
103 *
104 * 22 1/24/99 8:17p Chris
105 * Updated AI and OSIRIS. Externalized fireball constants for spew and
106 * sparks. Added CreateRandomSparks to OSIRIS, renamed a bunch of AI
107 * Notify names to use underscores. Fixed a memory access leak in the
108 * matcen effect code.
109 *
110 * 21 1/22/99 4:47p Jeff
111 *
112 * 20 1/20/99 4:16p Jeff
113 * added ai notify child events and predefs to get ids of sound, room,
114 * trigger, object names
115 *
116 * 19 1/20/99 1:01a Chris
117 * Improved AI and OSIRIS intergration
118 *
119 * 18 1/15/99 5:59p Chris
120 *
121 * 17 1/13/99 5:20p Jeff
122 * added 4 new file operation predefs
123 *
124 * 16 1/13/99 3:25a Chris
125 * Added Obj_Burning and Obj_IsEffect to OSIRIS
126 *
127 * 15 1/13/99 2:29a Chris
128 * Massive AI, OSIRIS update
129 *
130 * 14 1/11/99 2:14p Chris
131 * Massive work on OSIRIS and AI
132 *
133 * 13 1/05/99 12:24p Chris
134 * More OSIRIS improvements
135 *
136 * 12 1/04/99 6:43p Jeff
137 * added support to get/set mission flag values
138 *
139 * 11 1/04/99 12:42p Chris
140 * Updated OSIRIS with "xxxx_external.h" files and Obj_Value, and
141 * Matcen_XXX functions
142 *
143 * 10 12/30/98 3:46p Chris
144 * Incremental AI changes
145 *
146 * 9 12/23/98 12:10p Chris
147 * Added Gametime and Frametime to OSIRIS
148 *
149 * 8 12/22/98 4:52p Chris
150 * Added another defualt parameter to Objcreate
151 *
152 * 7 12/22/98 4:51p Chris
153 * Added a ObjCreate predefined function
154 *
155 * 6 12/22/98 2:46p Chris
156 * Added the AIValue predefined function
157 *
158 * 5 12/21/98 5:30p Samir
159 * predef for determining if object is being rendered.
160 *
161 * 4 12/17/98 6:42p Samir
162 * added functions to manipulate player controls
163 *
164 * 3 12/17/98 5:43p Jeff
165 * created timer system for osiris and save restore events
166 *
167 * 2 12/16/98 10:14p Jeff
168 * created osiris predefined function file
169 *
170 * $NoKeywords: $
171 */
172
173 #ifndef __OSIRIS_PREDEF_H_
174 #define __OSIRIS_PREDEF_H_
175
176 #include "osiris_dll.h"
177 #include "cfile.h"
178
179 // osipf_CallObjectEvent
180 // Sends an event to an object. Returns true if the default action should
181 // continue to process.
182 bool osipf_CallObjectEvent(int objnum, int event, tOSIRISEventInfo *ei);
183
184 // osipf_CallTriggerEvent
185 // Sends an event to a trigger. Returns true if the default action should
186 // continue to process.
187 bool osipf_CallTriggerEvent(int trignum, int event, tOSIRISEventInfo *ei);
188
189 // Touches a sound file so it loads into memory
190 void osipf_SoundTouch(char *str);
191
192 // searches for an object id given it's name
193 int osipf_ObjectFindID(const char *name);
194
195 int osipf_ObjectFindType(const char *name);
196
197 // searches through the weapons for a name and returns the id
198 int osipf_WeaponFindID(const char *name);
199
200 // returns how long an object has lived
201 float osipf_ObjectGetTimeLived(int objhandle);
202
203 void osipf_GetGunPos(int objhandle, int gun_number, vector *gun_pnt, vector *gun_normal = NULL);
204
205 // Returns room values (Index is optional and not always used)
206 void osipf_RoomValue(int roomnum, char op, char vhandle, void *ptr, int index = 0);
207 uint8_t osipf_IsRoomValid(int roomnum);
208
209 // Returns player only values (Index is optional and not always used)
210 void osipf_PlayerValue(int obj_handle, char op, char vhandle, void *ptr, int index = 0);
211 void osipf_ObjectCustomAnim(int handle, float start, float end, float time, char flags, int sound_handle = -1,
212 char next_anim_type = -1);
213
214 int osipf_GetAttachParent(int childhandle);
215 int osipf_GetNumAttachSlots(int objhandle);
216 int osipf_GetAttachChildHandle(int objhandle, char attachpoint);
217 int osipf_AttachObjectAP(int parenthandle, char parent_ap, int childhandle, char child_ap, uint8_t f_use_aligned);
218 int osipf_AttachObjectRad(int parenthandle, char parent_ap, int childhandle, float percent_rad);
219 void osipf_UnattachFromParent(int objhandle);
220 void osipf_UnattachChild(int objhandle, char parent_ap);
221 void osipf_UnattachChildren(int objhandle);
222
223 int osipf_RayCast(int objhandle, vector *p0, vector *p1, int start_roomnum, float rad, int flags, ray_info *ri);
224
225 // searches through GamePath index and returns index of path matching name
226 // returns -1 if not found
227 int osipf_AIGetPathID(char *string);
228 vector osipf_AIFindHidePos(int hideobjhandle, int viewobjhandle, float time, int *hide_room);
229 int osipf_AIFindObjOfType(int objhandle, int type, int id, bool f_ignore_init_room,
230 int parent_handle = OBJECT_HANDLE_NONE);
231 vector osipf_AIGetRoomPathPoint(int roomnum);
232 int osipf_AIFindEnergyCenter(int objhandle);
233 float osipf_AIGetDistToObj(int objhandle, int otherobjhandle);
234
235 void osipf_AISetType(int objhandle, int type);
236 int osipf_AIPowerSwitch(int objhandle, uint8_t f_power_on);
237
238 int osipf_AIGoalAdd(int objhandle, int goal_type, int level, float influence, int guid, int flags, ...);
239 int osipf_AIGoalAddEnabler(int objhandle, int goal_index, int enabler_type, float percent, float interval, void *ptr);
240 void osipf_AIGoalClear(int objhandle, int goal_index);
241 int osipf_AIGoalFollowPathSimple(int objhandle, int path_id, int guid, int flags, int slot = 3);
242 void osipf_AISetGoalCircleDist(int objhandle, int goal_handle, float dist);
243 int osipf_AISetGoalFlags(int objhandle, int goal_handle, int flags, uint8_t f_enable);
244
245 uint8_t osipf_AITurnTowardsVectors(int objhandle, vector *fvec, vector *uvec);
246 uint8_t osipf_AIMoveTowardsPosition(int objhandle, vector *pos, int *roomnum, float scalar, bool f_bline,
247 bool f_bline_if_vis);
248 uint8_t osipf_AIMoveTowardsDir(int objhandle, vector *dir, float scalar);
249
250 void osipf_AIValue(int objhandle, char op, char vtype, void *ptr);
251
252 // Reads the specified number of bytes from a file into the buffer
253 // DO NOT USE THIS TO READ STRUCTURES. This function is for byte
254 // data, such as a string or a bitmap of 8-bit pixels.
255 // Returns the number of bytes read.
256 // Throws an exception of type (cfile_error *) if the OS returns an error on read
257 int osipf_CFReadBytes(uint8_t *buffer, int count, CFILE *cfp);
258
259 // The following functions read numeric vales from a CFILE. All values are
260 // stored in the file in Intel (little-endian) format. These functions
261 // will convert to big-endian if required.
262 // These funtions will throw an exception of if the value cannot be read,
263 // so do not call these if you don't require the data to be present.
264
265 // Read and return an integer (32 bits)
266 // Throws an exception of type (cfile_error *) if the OS returns an error on read
267 int osipf_CFReadInt(CFILE *cfp);
268
269 // Read and return a int16_t (16 bits)
270 // Throws an exception of type (cfile_error *) if the OS returns an error on read
271 int16_t osipf_CFReadShort(CFILE *cfp);
272
273 // Read and return a byte (8 bits)
274 // Throws an exception of type (cfile_error *) if the OS returns an error on read
275 int8_t osipf_CFReadByte(CFILE *cfp);
276
277 // Read and return a float (32 bits)
278 // Throws an exception of type (cfile_error *) if the OS returns an error on read
279 float osipf_CFReadFloat(CFILE *cfp);
280
281 // Read and return a double (64 bits)
282 // Throws an exception of type (cfile_error *) if the OS returns an error on read
283 double osipf_CFReadDouble(CFILE *cfp);
284
285 // Reads a string from a CFILE. If the file is type binary, this
286 // function reads until a NULL or EOF is found. If the file is text,
287 // the function reads until a newline or EOF is found. The string is always
288 // written to the destination buffer null-terminated, without the newline.
289 // Parameters: buf - where the string is written
290 // n - the maximum string length, including the terminating 0
291 // cfp - the CFILE pointer
292 // Returns the number of bytes in the string, before the terminator
293 // Does not generate an exception on EOF
294 int osipf_CFReadString(char *buf, size_t n, CFILE *cfp);
295
296 // Writes the specified number of bytes from a file into the buffer
297 // DO NOT USE THIS TO WRITE STRUCTURES. This function is for byte
298 // data, such as a string or a bitmap of 8-bit pixels.
299 // Returns the number of bytes written.
300 // Throws an exception of type (cfile_error *) if the OS returns an error on write
301 int osipf_CFWriteBytes(const uint8_t *buf, int count, CFILE *cfp);
302
303 // Writes a null-terminated string to a file. If the file is type binary,
304 // the string is terminated in the file with a null. If the file is type
305 // text, the string is terminated with a newline.
306 // Parameters: buf - pointer to the string
307 // cfp = the CFILE pointer
308 // Returns the number of bytes written
309 // Throws an exception of type (cfile_error *) if the OS returns an error on write
310 int osipf_CFWriteString(const char *buf, CFILE *cfp);
311
312 // The following functions write numeric vales to a CFILE. All values are
313 // stored to the file in Intel (little-endian) format.
314 // All these throw an exception if there's an error on write.
315
316 // Write an integer (32 bits)
317 // Throws an exception of type (cfile_error *) if the OS returns an error on write
318 void osipf_CFWriteInt(int i, CFILE *cfp);
319
320 // Write a int16_t (16 bits)
321 // Throws an exception of type (cfile_error *) if the OS returns an error on write
322 void osipf_CFWriteShort(int16_t s, CFILE *cfp);
323
324 // Write a byte (8 bits). If the byte is a newline & the file is a text file, writes a CR/LF pair.
325 // Throws an exception of type (cfile_error *) if the OS returns an error on write
326 void osipf_CFWriteByte(int8_t b, CFILE *cfp);
327
328 // Write a float (32 bits)
329 // Throws an exception of type (cfile_error *) if the OS returns an error on write
330 void osipf_CFWriteFloat(float f, CFILE *cfp);
331
332 // Write a double (64 bits)
333 // Throws an exception of type (cfile_error *) if the OS returns an error on write
334 void osipf_CFWriteDouble(double d, CFILE *cfp);
335
336 // CONTROLLER predefs
337 // enables or disables controls specified.
338 void osipf_SetAllControls(bool enabled);
339
340 // enable or disable specified function
341 void osipf_SetControls(int fn, bool enabled);
342
343 // Creates an object
344 int osipf_ObjCreate(uint8_t type, uint16_t id, int roomnum, vector *pos, const matrix *orient = NULL,
345 int parent_handle = OBJECT_HANDLE_NONE, vector *velocity = NULL);
346
347 // OBJECT Properties.
348 // is an object visible? (rendered current frame)
349 bool osipf_IsObjectVisible(object *obj);
350
351 float osipf_GameTime(void);
352 float osipf_FrameTime(void);
353 void osipf_ObjWBValue(int obj_handle, char wb_index, char op, char vtype, void *ptr, char g_index = 0);
354
355 void osipf_ObjectValue(int handle, char op, char vtype, void *ptr, int index = 0);
356 void osipf_MatcenValue(int handle, char op, char vtype, void *ptr, int index = 0);
357
358 void osipf_MatcenReset(int handle);
359 void osipf_MatcenCopy(int dhandle, int shandle);
360 int osipf_MatcenCreate(char *name);
361 int osipf_MatcenFindId(char *str);
362
363 // Sets/Clears mission flags
364 // flag is which mission flag to set/clear (1-32)
365 // value is 0 to clear, or 1 to set
366 void osipf_MissionFlagSet(int flag, uint8_t value);
367
368 // Gets a mission flag
369 // flag is what mission flag to get. Returns 1 if set, 0 if not.
370 int osipf_MissionFlagGet(int flag);
371
372 void osipf_PlayerAddHudMessage(int handle, const char *str);
373 void osipf_ObjGhost(int handle, bool f_ghost);
374 void osipf_ObjBurning(int handle, float time, float damage_per_second);
375 bool osipf_ObjIsEffect(int handle, int type_flag);
376
377 // opens a cfile for reading/writing (works just like fopen())
378 void *osipf_CFopen(const char *filename, const char *mode);
379
380 // closes a cfile (like fclose())
381 void osipf_CFclose(CFILE *file);
382
383 // returns the current position of the file (like ftell())
384 int osipf_CFtell(CFILE *file);
385
386 // returns 1 if the file is at the EOF, else 0 (like feof())
387 uint8_t osipf_CFeof(CFILE *file);
388
389 void osipf_SoundStop(int s_handle, bool f_immediately = false);
390 int osipf_SoundPlay2d(int obj_handle, int s_id, float volume = 1.0f);
391 int osipf_SoundPlay3d(int obj_handle, int s_id, float volume = 1.0f);
392 int osipf_SoundFindId(const char *s_name);
393
394 bool osipf_AIIsObjFriend(int obj_handle, int it_handle);
395 bool osipf_AIIsObjEnemy(int obj_handle, int it_handle);
396 void osipf_AIGoalValue(int obj_handle, char g_index, char op, char vtype, void *ptr, char index = 0);
397 int osipf_AIGetNearbyObjs(vector *pos, int init_roomnum, float rad, int *object_handle_list, int max_elements,
398 bool f_lightmap_only, bool f_only_players_and_ais = true,
399 bool f_include_non_collide_objects = false, bool f_stop_at_closed_doors = true);
400 char osipf_AIGetCurGoalIndex(int obj_handle);
401
402 int osipf_FindSoundName(const char *name);
403 int osipf_FindRoomName(const char *name);
404 int osipf_FindTriggerName(const char *name);
405 int osipf_FindObjectName(const char *name);
406 int osipf_GetTriggerRoom(int trigger_id);
407 int osipf_GetTriggerFace(int trigger_id);
408 int osipf_FindDoorName(const char *name);
409 int osipf_FindTextureName(const char *name);
410 int osipf_FindMatcenName(const char *name);
411 int osipf_FindPathName(const char *name);
412 int osipf_FindLevelGoalName(const char *name);
413
414 void osipf_CreateRandomSparks(int num_sparks, vector *pos, int roomnum, int which_index, float force_scalar);
415
416 void osipf_GetGroundPos(int objhandle, int ground_number, vector *ground_pnt, vector *ground_normal);
417
418 // disable/enable ship
419 void osipf_EnableShip(char *ship_name, bool enable);
420 // is ship enabled
421 bool osipf_IsShipEnabled(char *ship_name);
422
423 // turns the given player into AI mode or back to regular control mode
424 void osipf_SetPlayerControlMode(int pnum, bool set_to_ai);
425
426 // gets information about a path point
427 // pass NULL for parameters not needed.
428 // pathid: path number
429 // point: which path point
430 // returns true if operation was successful
431 bool osipf_PathGetInformation(int pathid, int point, vector *pos, int *room, matrix *orient);
432
433 void osipf_LGoalValue(char op, char vtype, void *ptr, int g_index = -1, int i_index = -1);
434 int osipf_ObjMakeListOfType(int objhandle, int type, int id, bool f_ignore_init_room, int parent_handle,
435 int max_recorded, int *handles);
436
437 void osipf_ObjKill(int handle, int killer_handle, float damage, int flags, float min_time, float max_time);
438 bool osipf_AIIsDestReachable(int handle, int room);
439 bool osipf_AIIsObjReachable(int handle, int target);
440 char osipf_GameGetDiffLevel(void);
441 int osipf_GetLanguageSetting(void);
442
443 // Sets/Gets information about a path.
444 // If you change is PV_ALL (or any of it's individual components), pass in a pointer to an
445 // osiris_path_node_info struct. For the others, you must pass in an appropriate pointer
446 // (i.e. an int* for PV_I_NUMNODES). You can only set PV_ALL components.
447 // for PV_I_NUMNODES, path_id MUST be specified, node_id is ignored
448 // for PV_I_NUMPATHS, path_id and node_id are ignored
449 // for PV_CS_NAME, path_id MUST be specified, node_id is ignored
450 // for PV_ALL components, path_id and node_id MUST be valid.
451 void osipf_PathValue(int path_id, int node_id, char op, int changes, void *ptr);
452
453 #endif