AISTRUCT.H 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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/aistruct.h $
  15. * $Revision: 2.0 $
  16. * $Author: john $
  17. * $Date: 1995/02/27 11:30:19 $
  18. *
  19. * Structs and constants for AI system.
  20. * object.h depends on this.
  21. * ai.h depends on object.h.
  22. * Get it?
  23. *
  24. * $Log: aistruct.h $
  25. * Revision 2.0 1995/02/27 11:30:19 john
  26. * New version 2.0, which has no anonymous unions, builds with
  27. * Watcom 10.0, and doesn't require parsing BITMAPS.TBL.
  28. *
  29. * Revision 1.34 1995/01/25 13:50:46 mike
  30. * Robots make angry sounds.
  31. *
  32. * Revision 1.33 1994/12/29 12:44:56 rob
  33. * Added new coop robot flag.
  34. *
  35. * Revision 1.32 1994/12/20 20:41:54 rob
  36. * Added new ai flag for multiplayer robots.
  37. *
  38. * Revision 1.31 1994/12/19 16:37:39 rob
  39. * Added a new flag for remote controlled objects.
  40. *
  41. * Revision 1.30 1994/12/07 00:36:07 mike
  42. * fix phys_apply_rot for robots -- ai was bashing effect in next frame.
  43. *
  44. * Revision 1.29 1994/12/02 22:06:28 mike
  45. * add fields to allow robots to make awareness sounds every so often, not every damn blasted frame
  46. *
  47. * Revision 1.28 1994/11/04 17:18:35 yuan
  48. * Increased MAX_SEG_POINTS to 2500.
  49. *
  50. * Revision 1.27 1994/10/17 21:19:22 mike
  51. * robot cloaking.
  52. *
  53. * Revision 1.26 1994/10/12 21:28:38 mike
  54. * Add new ai mode: AIM_OPEN_DOOR.
  55. * Add GOALSIDE to aip.
  56. *
  57. * Revision 1.25 1994/09/25 23:41:08 matt
  58. * Changed the object load & save code to read/write the structure fields one
  59. * at a time (rather than the whole structure at once). This mean that the
  60. * object structure can be changed without breaking the load/save functions.
  61. * As a result of this change, the local_object data can be and has been
  62. * incorporated into the object array. Also, timeleft is now a property
  63. * of all objects, and the object structure has been otherwise cleaned up.
  64. *
  65. * Revision 1.24 1994/09/21 12:28:11 mike
  66. * Change AI behavior for when player cloaked
  67. *
  68. * Revision 1.23 1994/09/19 21:43:00 mike
  69. * Add follow_path_start_seg and follow_path_end_seg to aistruct.h.
  70. *
  71. * Revision 1.22 1994/09/18 18:06:14 mike
  72. * Add Last_uncloaked_time and Last_uncloaked_position variables.
  73. *
  74. * Revision 1.21 1994/09/15 16:31:38 mike
  75. * Define GREEN_GUY
  76. * Add previous_visibility to ai_local struct.
  77. *
  78. * Revision 1.20 1994/09/12 19:12:45 mike
  79. * Change some bytes to ints in ai_local so I could set watchpoints.
  80. *
  81. * Revision 1.19 1994/08/25 21:53:31 mike
  82. * Add behavior, taking place of what used to be mode.
  83. *
  84. * Revision 1.18 1994/08/23 16:38:09 mike
  85. * rapidfire_count in ai_local.
  86. *
  87. * Revision 1.17 1994/08/19 17:38:23 mike
  88. * *** empty log message ***
  89. *
  90. * Revision 1.16 1994/08/17 22:18:58 mike
  91. * add time_since_processed to ai_local.
  92. *
  93. * Revision 1.15 1994/08/10 19:52:25 mike
  94. * Add Overall_agitation.
  95. *
  96. * Revision 1.14 1994/08/04 16:32:32 mike
  97. * Add time_player_seen.
  98. *
  99. * Revision 1.13 1994/07/28 16:58:11 mike
  100. * Move constants from ai.c
  101. *
  102. * Revision 1.12 1994/07/19 15:26:24 mike
  103. * New ai_static and ai_local structures.
  104. *
  105. * Revision 1.11 1994/07/15 15:17:19 matt
  106. * Changes MAX_AI_FLAGS for better alignment
  107. *
  108. */
  109. #ifndef _AISTRUCT_H
  110. #define _AISTRUCT_H
  111. #include "inferno.h"
  112. //#include "polyobj.h"
  113. #define GREEN_GUY 1
  114. #define MAX_SEGMENTS_PER_PATH 20
  115. #define PA_WEAPON_WALL_COLLISION 2 // Level of robot awareness after player weapon hits nearby wall
  116. //#define PA_PLAYER_VISIBLE 2 // Level of robot awareness if robot is looking towards player, and player not hidden
  117. #define PA_NEARBY_ROBOT_FIRED 1 // Level of robot awareness after nearby robot fires a weapon
  118. #define PA_PLAYER_COLLISION 3 // Level of robot awareness after player bumps into robot
  119. #define PA_WEAPON_ROBOT_COLLISION 4 // Level of robot awareness after player weapon hits nearby robot
  120. // #define PAE_WEAPON_HIT_WALL 1 // weapon hit wall, create player awareness
  121. // #define PAE_WEAPON_HIT_ROBOT 2 // weapon hit wall, create player awareness
  122. // Constants indicating currently moving forward or backward through path.
  123. // Note that you can add aip->direction to aip_path_index to get next segment on path.
  124. #define AI_DIR_FORWARD 1
  125. #define AI_DIR_BACKWARD (-AI_DIR_FORWARD)
  126. // Behaviors
  127. #define AIB_STILL 0x80
  128. #define AIB_NORMAL 0x81
  129. #define AIB_HIDE 0x82
  130. #define AIB_RUN_FROM 0x83
  131. #define AIB_FOLLOW_PATH 0x84
  132. #define AIB_STATION 0x85
  133. #define MIN_BEHAVIOR 0x80
  134. #define MAX_BEHAVIOR 0x85
  135. // Modes
  136. #define AIM_STILL 0
  137. #define AIM_WANDER 1
  138. #define AIM_FOLLOW_PATH 2
  139. #define AIM_CHASE_OBJECT 3
  140. #define AIM_RUN_FROM_OBJECT 4
  141. #define AIM_HIDE 5
  142. #define AIM_FOLLOW_PATH_2 6
  143. #define AIM_OPEN_DOOR 7
  144. #define AISM_GOHIDE 0
  145. #define AISM_HIDING 1
  146. #define AI_MAX_STATE 7
  147. #define AI_MAX_EVENT 4
  148. #define AIS_NONE 0
  149. #define AIS_REST 1
  150. #define AIS_SRCH 2
  151. #define AIS_LOCK 3
  152. #define AIS_FLIN 4
  153. #define AIS_FIRE 5
  154. #define AIS_RECO 6
  155. #define AIS_ERR_ 7
  156. #define AIE_FIRE 0
  157. #define AIE_HITT 1
  158. #define AIE_COLL 2
  159. #define AIE_HURT 3
  160. //typedef struct opath {
  161. // byte path_index; // current index of path
  162. // byte path_direction; // current path direction
  163. // byte path_length; // length of current path
  164. // byte nothing;
  165. // short path[MAX_SEGMENTS_PER_PATH];
  166. // short always_0xabc; // If this is ever not 0xabc, then someone overwrote
  167. //} opath;
  168. //
  169. //typedef struct oai_state {
  170. // short mode; //
  171. // short counter; // kind of a hack, frame countdown until switch modes
  172. // opath paths[2];
  173. // vms_vector movement_vector; // movement vector for one second
  174. //} oai_state;
  175. // Constants defining meaning of flags in ai_state
  176. #define MAX_AI_FLAGS 11 // This MUST cause word (4 bytes) alignment in ai_static, allowing for one byte mode
  177. #define CURRENT_GUN flags[0] // This is the last gun the object fired from
  178. #define CURRENT_STATE flags[1] // current behavioral state
  179. #define GOAL_STATE flags[2] // goal state
  180. #define PATH_DIR flags[3] // direction traveling path, 1 = forward, -1 = backward, other = error!
  181. #define SUBMODE flags[4] // submode, eg AISM_HIDING if mode == AIM_HIDE
  182. #define GOALSIDE flags[5] // for guys who open doors, this is the side they are going after.
  183. #define CLOAKED flags[6] // Cloaked now.
  184. #define SKIP_AI_COUNT flags[7] // Skip AI this frame, but decrement in do_ai_frame.
  185. #define REMOTE_OWNER flags[8] // Who is controlling this remote AI object (multiplayer use only)
  186. #define REMOTE_SLOT_NUM flags[9] // What slot # is this robot in for remote control purposes (multiplayer use only)
  187. #define MULTI_ANGER flags[10] // How angry is a robot in multiplayer mode
  188. // This is the stuff that is permanent for an AI object and is therefore saved to disk.
  189. typedef struct ai_static {
  190. ubyte behavior; //
  191. byte flags[MAX_AI_FLAGS]; // various flags, meaning defined by constants
  192. short hide_segment; // Segment to go to for hiding.
  193. short hide_index; // Index in Path_seg_points
  194. short path_length; // Length of hide path.
  195. short cur_path_index; // Current index in path.
  196. short follow_path_start_seg; // Start segment for robot which follows path.
  197. short follow_path_end_seg; // End segment for robot which follows path.
  198. int danger_laser_signature;
  199. short danger_laser_num;
  200. // byte extras[28]; // 32 extra bytes for storing stuff so we don't have to change versions on disk
  201. } ai_static;
  202. // This is the stuff which doesn't need to be saved to disk.
  203. typedef struct ai_local {
  204. // These used to be bytes, changed to ints so I could set watchpoints on them.
  205. byte player_awareness_type; // type of awareness of player
  206. byte retry_count; // number of retries in physics last time this object got moved.
  207. byte consecutive_retries; // number of retries in consecutive frames (ie, without a retry_count of 0)
  208. byte mode; // current mode within behavior
  209. byte previous_visibility; // Visibility of player last time we checked.
  210. byte rapidfire_count; // number of shots fired rapidly
  211. short goal_segment; // goal segment for current path
  212. fix last_see_time, last_attack_time; // For sound effects, time at which player last seen, attacked
  213. fix wait_time; // time in seconds until something happens, mode dependent
  214. fix next_fire; // time in seconds until can fire again
  215. fix player_awareness_time; // time in seconds robot will be aware of player, 0 means not aware of player
  216. fix time_player_seen; // absolute time in seconds at which player was last seen, might cause to go into follow_path mode
  217. fix time_player_sound_attacked; // absolute time in seconds at which player was last seen with visibility of 2.
  218. fix next_misc_sound_time; // absolute time in seconds at which this robot last made an angry or lurking sound.
  219. fix time_since_processed; // time since this robot last processed in do_ai_frame
  220. vms_angvec goal_angles[MAX_SUBMODELS]; //angles for each subobject
  221. vms_angvec delta_angles[MAX_SUBMODELS]; //angles for each subobject
  222. byte goal_state[MAX_SUBMODELS]; // Goal state for this sub-object
  223. byte achieved_state[MAX_SUBMODELS]; // Last achieved state
  224. } ai_local;
  225. typedef struct {
  226. int segnum;
  227. vms_vector point;
  228. } point_seg;
  229. typedef struct {
  230. short start, end;
  231. } seg_seg;
  232. #define MAX_POINT_SEGS 2500
  233. extern point_seg Point_segs[MAX_POINT_SEGS];
  234. extern point_seg *Point_segs_free_ptr;
  235. extern int Overall_agitation;
  236. // These are the information for a robot describing the location of the player last time he wasn't cloaked,
  237. // and the time at which he was uncloaked. We should store this for each robot, but that's memory expensive.
  238. //extern fix Last_uncloaked_time;
  239. //extern vms_vector Last_uncloaked_position;
  240. extern void ai_do_cloak_stuff(void);
  241. #endif