O.H 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. /*
  2. THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
  3. SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
  4. END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
  5. ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
  6. IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
  7. SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
  8. FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
  9. CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
  10. AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
  11. COPYRIGHT 1993-1998 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
  12. */
  13. /*
  14. * $Source: f:/miner/source/main/rcs/object.h $
  15. * $Revision: 1.75 $
  16. * $Author: matt $
  17. * $Date: 1994/08/03 21:06:19 $
  18. *
  19. * object system definitions
  20. *
  21. * $Log: object.h $
  22. * Revision 1.75 1994/08/03 21:06:19 matt
  23. * Added prototype for fix_object_segs(), and renamed now-unused spawn_pos
  24. *
  25. * Revision 1.74 1994/08/02 12:30:27 matt
  26. * Added support for spinning objects
  27. *
  28. * Revision 1.73 1994/07/27 20:53:25 matt
  29. * Added rotational drag & thrust, so turning now has momemtum like moving
  30. *
  31. * Revision 1.72 1994/07/27 19:44:21 mike
  32. * Objects containing objects.
  33. *
  34. * Revision 1.71 1994/07/22 20:43:29 matt
  35. * Fixed flares, by adding a physics flag that makes them stick to walls.
  36. *
  37. * Revision 1.70 1994/07/21 12:42:10 mike
  38. * Prototype new find_object_seg and update_object_seg.
  39. *
  40. * Revision 1.69 1994/07/19 15:26:39 mike
  41. * New ai_static structure.
  42. *
  43. * Revision 1.68 1994/07/13 00:15:06 matt
  44. * Moved all (or nearly all) of the values that affect player movement to
  45. * bitmaps.tbl
  46. *
  47. * Revision 1.67 1994/07/12 12:40:12 matt
  48. * Revamped physics system
  49. *
  50. * Revision 1.66 1994/07/06 15:26:23 yuan
  51. * Added chase mode.
  52. *
  53. * Revision 1.65 1994/06/29 19:43:31 matt
  54. * Made powerup animation not happen in render routine
  55. *
  56. * Revision 1.64 1994/06/27 18:31:09 mike
  57. * Add flares.
  58. *
  59. * Revision 1.63 1994/06/14 21:15:21 matt
  60. * Made rod objects draw lighted or not depending on a parameter, so the
  61. * materialization effect no longer darkens.
  62. *
  63. * Revision 1.62 1994/06/14 16:55:00 matt
  64. * Got rid of physics_object speed field
  65. *
  66. * Revision 1.61 1994/06/09 16:24:58 matt
  67. * Fixed confusion with two constants, MAX_SUBOBJS & MAX_SUBMODELS, which
  68. * were used for the same things, but had different values.
  69. *
  70. * Revision 1.60 1994/06/08 10:56:44 matt
  71. * Improved debris: now get submodel size from new POF files; debris now has
  72. * limited life; debris can now be blown up.
  73. *
  74. * Revision 1.59 1994/06/02 19:30:49 matt
  75. * Moved texture-mapped rod drawing stuff (used for hostage & now for the
  76. * materialization center) to object.c
  77. *
  78. * Revision 1.58 1994/05/30 22:50:20 matt
  79. * Added morph effect for robots
  80. *
  81. * Revision 1.57 1994/05/30 19:46:47 mike
  82. * Move MAX_SUBOBJS from here to inferno.h
  83. *
  84. * Revision 1.56 1994/05/30 00:03:19 matt
  85. * Got rid of robot render type, and generally cleaned up polygon model
  86. * render objects.
  87. *
  88. * Revision 1.55 1994/05/26 21:08:44 matt
  89. * Moved robot stuff out of polygon model and into robot_info struct
  90. * Made new file, robot.c, to deal with robots
  91. *
  92. * Revision 1.54 1994/05/20 11:56:59 matt
  93. * Cleaned up find_vector_intersection() interface
  94. * Killed check_point_in_seg(), check_player_seg(), check_object_seg()
  95. *
  96. * Revision 1.53 1994/05/19 18:53:18 yuan
  97. * Changing player structure...
  98. *
  99. * Revision 1.52 1994/05/17 12:36:16 matt
  100. * Changed parms to obj_create() and cleaned up object creation code
  101. *
  102. * Revision 1.51 1994/05/17 11:53:45 yuan
  103. * Adding Player_init, which saves position of player at beginning of level.
  104. *
  105. * Revision 1.50 1994/05/17 10:37:08 matt
  106. * Added new parm to reset_objects(), made Num_objects not public, added
  107. * Highest_object_index().
  108. *
  109. * Revision 1.49 1994/05/16 16:48:14 yuan
  110. * Added symbolic constant OBJECT_INITIAL_SHIELDS
  111. *
  112. * Revision 1.48 1994/05/16 16:17:47 john
  113. * Bunch of stuff on my Inferno Task list May16-23
  114. *
  115. * Revision 1.47 1994/05/16 10:12:12 matt
  116. * Added prototype for init_player_object()
  117. *
  118. * Revision 1.46 1994/05/14 17:15:06 matt
  119. * Got rid of externs in source (non-header) files
  120. *
  121. * Revision 1.45 1994/05/13 20:27:37 john
  122. * Version II of John's new object code.
  123. *
  124. * Revision 1.44 1994/05/12 14:44:39 mike
  125. * Add ai_info to object structure.
  126. *
  127. * Revision 1.43 1994/05/11 23:33:08 mike
  128. * Make RESULT_KILLS directional with RESULT_KILLS_1_2 and RESULT_KILLS_2_1.
  129. *
  130. * Revision 1.42 1994/05/10 18:02:16 mike
  131. * Increase MAX_OBJECTS from 100 to 200
  132. *
  133. * Revision 1.41 1994/05/07 16:42:07 matt
  134. * Changed name of turnbank to turnroll
  135. *
  136. * Revision 1.40 1994/05/06 10:12:39 matt
  137. * Added new function, obj_create_copy()
  138. *
  139. * Revision 1.39 1994/05/05 20:39:33 matt
  140. * Made physics code more general-purpose; moved code from object.c to
  141. * physics.c; renamed routines; made behavior such as levelling and turn
  142. * banking controllable by flags.
  143. *
  144. * Revision 1.38 1994/05/05 16:41:12 matt
  145. * Cleaned up repair center code, and moved some from object.c to fuelcen.c
  146. *
  147. * Revision 1.37 1994/05/03 19:33:40 matt
  148. * Cleaned up usage of rotvel field from physics_info structure
  149. *
  150. * Revision 1.36 1994/05/02 18:34:14 matt
  151. * Changed parms to obj_link(), added a little more error checking, changed
  152. * a few fields in object physics_info, and probably a few other little things.
  153. *
  154. * Revision 1.35 1994/05/02 16:30:31 john
  155. * Added object flag OF_SHOULD_BE_DEAD which fixed the bug
  156. * that caused very close robots to die 10 seconds after they
  157. * actually got shot.
  158. *
  159. * Revision 1.34 1994/04/29 09:18:08 matt
  160. * Added support for multiple-piece explosions
  161. *
  162. * Revision 1.33 1994/04/07 16:28:07 yuan
  163. * Added SUPERPIG the robot with 200 hit points.
  164. * Now robots can take multiple hits before blowing up.
  165. *
  166. * Revision 1.32 1994/04/07 13:44:13 yuan
  167. * Added powerup_info to object structure.
  168. *
  169. * Revision 1.31 1994/04/01 13:34:15 matt
  170. * Cleaned up explosion and laser code; added mutliple-stage explosions.
  171. *
  172. * Revision 1.30 1994/04/01 11:15:07 yuan
  173. * Added multiple bitmap functionality to all objects...
  174. * (hostages, powerups, lasers, etc.)
  175. * Hostages and powerups are implemented in the object system,
  176. * just need to finish function call to "affect" player.
  177. *
  178. * Revision 1.29 1994/03/31 09:07:43 matt
  179. * Made last_pos a field of all objects, not just lasers
  180. *
  181. * Revision 1.28 1994/03/30 21:14:33 yuan
  182. * Minor name change for object->damage...
  183. * object->lifeleft now.
  184. *
  185. * Revision 1.27 1994/03/28 20:57:36 yuan
  186. * *** empty log message ***
  187. *
  188. * Revision 1.26 1994/03/25 17:30:13 yuan
  189. * Checking in hostage stuff... (start of it)
  190. *
  191. * Revision 1.25 1994/03/25 16:54:55 matt
  192. * polyobj_info field of object structure now has data for object animation
  193. *
  194. * Revision 1.24 1994/02/17 11:32:50 matt
  195. * Changes in object system
  196. *
  197. *
  198. *
  199. */
  200. #ifndef _OBJECT_H
  201. #define _OBJECT_H
  202. #include "types.h"
  203. #include "vecmat.h"
  204. #include "segment.h"
  205. #include "gameseg.h"
  206. #include "aistruct.h"
  207. #include "gr.h"
  208. /*
  209. * CONSTANTS
  210. */
  211. #define MAX_OBJECTS 200 //total number of objects in world
  212. //Object types
  213. #define OBJ_NONE 255 //unused object
  214. #define OBJ_WALL 0 //A wall... not really an object, but used for collisions
  215. #define OBJ_FIREBALL 1 //a fireball, part of an explosion
  216. #define OBJ_ROBOT 2 //an evil enemy
  217. #define OBJ_HOSTAGE 3 //a hostage you need to rescue
  218. #define OBJ_PLAYER 4 //the player on the console
  219. #define OBJ_WEAPON 5 //a laser, missile, etc
  220. #define OBJ_CAMERA 6 //a camera to slew around with
  221. #define OBJ_POWERUP 7 //a powerup you can pick up
  222. #define OBJ_DEBRIS 8 //a piece of robot
  223. #define OBJ_CNTRLCEN 9 //the control center
  224. #define OBJ_FLARE 10 //the control center
  225. #define MAX_OBJECT_TYPES 11
  226. //Result types
  227. #define RESULT_NOTHING 0 //Ignore this collision
  228. #define RESULT_CHECK 1 //Check for this collision
  229. //Control types - what tells this object what do do
  230. #define CT_NONE 0 //doesn't move (or change movement)
  231. #define CT_AI 1 //driven by AI
  232. #define CT_EXPLOSION 2 //explosion sequencer
  233. #define CT_MULTIPLAYER 3 //via serial or network
  234. #define CT_FLYING 4 //the player is flying
  235. #define CT_SLEW 5 //slewing
  236. #define CT_FLYTHROUGH 6 //the flythrough system
  237. #define CT_DEMO 7 //recorded demo playing back
  238. //#define CT_ROBOT_FLYTHROUGH 8 //special flythrough for robots
  239. #define CT_WEAPON 9 //laser, etc.
  240. #define CT_REPAIRCEN 10 //under the control of the repair center
  241. #define CT_MORPH 11 //this object is being morphed
  242. #define CT_DEBRIS 12 //this is a piece of debris
  243. #define CT_POWERUP 13 //animating powerup blob
  244. //Movement types
  245. #define MT_NONE 0 //doesn't move
  246. #define MT_PHYSICS 1 //moves by physics
  247. #define MT_MULTIPLAYER 2 //another player (maybe just interpolation?)
  248. #define MT_SPINNING 3 //this object doesn't move, just sits and spins
  249. //Render types
  250. #define RT_NONE 0 //does not render
  251. #define RT_POLYOBJ 1 //a polygon model
  252. #define RT_FIREBALL 2 //a fireball
  253. #define RT_LASER 3 //a laser
  254. #define RT_HOSTAGE 4 //a hostage
  255. #define RT_POWERUP 5 //a powerup
  256. #define RT_MORPH 6 //a robot being morphed
  257. //misc object flags
  258. #define OF_EXPLODING 1 //this object is exploding
  259. #define OF_SHOULD_BE_DEAD 2 //this object should be dead, so next time we can, we should delete this object.
  260. //Different Weapon ID types...
  261. #define WEAPON_ID_LASER 0
  262. #define WEAPON_ID_MISSLE 1
  263. #define WEAPON_ID_CANNONBALL 2
  264. //Object Initial shields...
  265. #define OBJECT_INITIAL_SHIELDS F1_0/2
  266. //physics flags
  267. #define PF_TURNROLL 1 //roll when turning
  268. #define PF_LEVELLING 2 //level object with closest side
  269. #define PF_BOUNCE 4 //bounce (not slide) when hit will
  270. #define PF_WIGGLE 8 //wiggle while flying
  271. #define PF_STICK 16 //object sticks (stops moving) when hits wall
  272. /*
  273. * STRUCTURES
  274. */
  275. //information for physics sim for an object
  276. typedef struct physics_info {
  277. vms_vector velocity; //velocity vector of this object
  278. vms_vector thrust; //constant force applied to this object
  279. fix mass; //the mass of this object
  280. fix drag; //how fast this slows down
  281. fix brakes; //how much brakes applied
  282. vms_vector rotvel; //rotational velecity (angles)
  283. vms_vector rotthrust; //rotational acceleration
  284. fixang turnroll; //rotation caused by turn banking
  285. ushort flags; //misc physics flags
  286. } physics_info;
  287. //information on remotely-controlled object
  288. typedef struct mplayer_info {
  289. int dummy; //what will be here?
  290. } mplayer_info;
  291. //stuctures for different kinds of simulation
  292. typedef struct laser_info {
  293. fix lifeleft; // decreased by FrameTime each frame, if > 0 don't decrease.
  294. short parent_type; // The type of the parent of this object
  295. short parent_num; // The object's parent's number
  296. int parent_signature; // The object's parent's signature...
  297. vms_vector extra_vec1; // Used to draw the proper width of laser bolt. (Offset)
  298. } laser_info;
  299. typedef struct explosion_info {
  300. fix lifeleft; // decreased by FrameTime each frame, if > 0 don't decrease.
  301. vms_vector unused; // was spawn_pos
  302. fix spawn_time; // when lifeleft is < this, spawn another
  303. fix delete_time; // when to delete object
  304. short delete_objnum; // and what object to delete
  305. } explosion_info;
  306. typedef struct flythrough_info {
  307. vms_angvec angle_step; // Used in flythrough
  308. vms_vector heading; // Where we want to be heading...
  309. int ft_mode;
  310. } flythrough_info;
  311. typedef struct powerup_info {
  312. fix frametime;
  313. byte framenum;
  314. } powerup_info;
  315. //structures for different kinds of rendering
  316. typedef struct polyobj_info {
  317. int model_num; //which polygon model
  318. vms_angvec anim_angles[MAX_SUBMODELS]; //angles for each subobject
  319. int subobj_flags; //specify which subobjs to draw
  320. } polyobj_info;
  321. typedef struct object {
  322. int signature; // Every robot has a unique signature...
  323. ubyte type; // what type of object this is... robot, weapon, hostage, powerup, fireball
  324. ubyte id; // which form of object...which powerup, robot, etc.
  325. short next,prev; // id of next and previous connected object in Objects, -1 = no connection
  326. ubyte control_type; // how this object is controlled
  327. ubyte movement_type; // how this object moves
  328. ubyte render_type; // how this object renders
  329. ubyte flags; // misc flags
  330. short segnum; // segment number containing object
  331. segmasks segmasks; // does obj poke into other segs?
  332. vms_vector pos; // absolute x,y,z coordinate of center of object
  333. vms_matrix orient; // orientation of object in world
  334. fix size; // 3d size of object - for collision detection
  335. fix shields; // Starts at maximum, when <0, object dies..
  336. vms_vector last_pos; // where object was last frame
  337. byte contains_type; // Type of object this object contains (eg, spider contains powerup)
  338. byte contains_id; // ID of object this object contains (eg, id = blue type = key)
  339. byte contains_count; // number of objects of type:id this object contains
  340. byte dum1; // Unused.
  341. //movement info, determined by MOVEMENT_TYPE
  342. union {
  343. physics_info phys_info; //a physics object
  344. mplayer_info mplayer_info; //controled by remote player
  345. vms_vector spin_rate; //for spinning objects
  346. };
  347. //control info, determined by CONTROL_TYPE
  348. union {
  349. laser_info laser_info;
  350. explosion_info expl_info; //NOTE: debris uses this also
  351. ai_static ai_info;
  352. };
  353. //render info, determined by RENDER_TYPE
  354. union {
  355. polyobj_info pobj_info; //polygon model
  356. powerup_info powerup_info; //powerup (vclip)
  357. };
  358. } object;
  359. typedef struct obj_position {
  360. vms_vector pos; // absolute x,y,z coordinate of center of object
  361. vms_matrix orient; // orientation of object in world
  362. short segnum; // segment number containing object
  363. } obj_position;
  364. /*
  365. * VARIABLES
  366. */
  367. extern int Object_next_signature; // The next signature for the next newly created object
  368. extern ubyte CollisionResult[MAX_OBJECT_TYPES][MAX_OBJECT_TYPES];
  369. // ie CollisionResult[a][b]== what happens to a when it collides with b
  370. extern int Player_objnum;
  371. extern object Objects[];
  372. extern int Highest_object_index; //highest objnum
  373. extern int num_objects; //not really a public, included for
  374. extern grs_bitmap *robot_bms[]; //all bitmaps for all robots
  375. extern int robot_bm_nums[]; //starting bitmap num for each robot
  376. extern int robot_n_bitmaps[]; //how many bitmaps for each robot
  377. extern char *robot_names[]; //name of each robot
  378. extern int Num_robot_types;
  379. extern short free_obj_list[MAX_OBJECTS];
  380. extern object *Player; //pointer to the object that is the player
  381. extern object *Viewer; //which object we are seeing from
  382. extern object Follow;
  383. extern obj_position Player_init;
  384. /*
  385. * FUNCTIONS
  386. */
  387. //do whatever setup needs to be done
  388. void init_objects();
  389. //returns segment number object is in. Searches out from object's current
  390. //seg, so this shouldn't be called if the object has "jumped" to a new seg
  391. int obj_get_new_seg(object *obj);
  392. //when an object has moved into a new segment, this function unlinks it
  393. //from its old segment, and links it into the new segment
  394. void obj_relink(short objnum,int newsegnum);
  395. //move an object from one segment to another. unlinks & relinks
  396. void obj_set_new_seg(short objnum,int newsegnum);
  397. //links an object into a segment's list of objects.
  398. //takes object number and segment number
  399. void obj_link(int objnum,int segnum);
  400. //unlinks an object from a segment's list of objects
  401. void obj_unlink(int objnum);
  402. //initialize a new object. adds to the list for the given segment
  403. //returns the object number
  404. short obj_create(ubyte type,ubyte id,short segnum,vms_vector *pos,
  405. vms_matrix *orient,fix size,ubyte ctype,ubyte mtype,ubyte rtype);
  406. //make a copy of an object. returs num of new object
  407. short obj_create_copy(int objnum, vms_vector *new_pos, int newsegnum);
  408. //remove object from the world
  409. void obj_delete(short objnum);
  410. //called after load. Takes number of objects, and objects should be
  411. //compressed
  412. void reset_objects(int n_objs);
  413. //make object array non-sparse
  414. void compress_objects(void);
  415. //Render an object. Calls one of several routines based on type
  416. void render_object(object *obj);
  417. //Draw a blob-type object, like a fireball
  418. void draw_object_blob(object *obj,grs_bitmap *bitmap);
  419. //draw an object that is a texture-mapped rod
  420. void draw_object_tmap_rod(object *obj,grs_bitmap *bitmap,int lighted);
  421. //Deletes all objects that have been marked for death.
  422. void obj_delete_all_that_should_be_dead();
  423. // Toggles whether or not lock-boxes draw.
  424. void object_toggle_lock_targets();
  425. //move all objects for the current frame
  426. void object_move_all(); // moves all objects
  427. //set viewer object to next object in array
  428. void object_goto_next_viewer();
  429. //draw target boxes for nearby robots
  430. void object_render_targets(void);
  431. //move an object for the current frame
  432. void object_move_one( object * obj );
  433. //make object0 the player, setting all relevant fields
  434. void init_player_object();
  435. //check if object is in object->segnum. if not, check the adjacent segs.
  436. //if not any of these, returns false, else sets obj->segnum & returns true
  437. //callers should really use find_vector_intersection()
  438. //Note: this function is in gameseg.c
  439. int update_object_seg(struct object *obj);
  440. // Finds what segment *obj is in, returns segment number.
  441. // If not in any segment, returns -1.
  442. // Note: This function is defined in gameseg.h, but object.h depends on gameseg.h, and
  443. // object.h is where object is defined...get it?
  444. extern int find_object_seg(object * obj );
  445. // Calls find_object_seg and relinks object if segment has changed.
  446. extern int update_object_seg(object * obj );
  447. //go through all objects and make sure they have the correct segment numbers
  448. //used when debugging is on
  449. fix_object_segs();
  450. #endif