b_public.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. #ifndef __B_PUBLIC_H__
  2. #define __B_PUBLIC_H__
  3. #include "bstate.h"
  4. #include "AI.h"
  5. #define NPCAI_CHECK_WEAPON 0x00000001
  6. #define NPCAI_BURST_WEAPON 0x00000002
  7. #define NPCAI_MOVING 0x00000004
  8. #define NPCAI_TOUCHED_GOAL 0x00000008
  9. #define NPCAI_PUSHED 0x00000010
  10. #define NPCAI_NO_COLL_AVOID 0x00000020
  11. #define NPCAI_BLOCKED 0x00000040
  12. #define NPCAI_SUBBOSS_CHARACTER 0x00000080 //Alora, tough reborn
  13. #define NPCAI_OFF_PATH 0x00000100
  14. #define NPCAI_IN_SQUADPOINT 0x00000200
  15. #define NPCAI_STRAIGHT_TO_DESTPOS 0x00000400
  16. #define NPCAI_HEAVY_MELEE 0x00000800 //4x melee damage, dismemberment
  17. #define NPCAI_NO_SLOWDOWN 0x00001000
  18. #define NPCAI_LOST 0x00002000 //Can't nav to his goal
  19. #define NPCAI_SHIELDS 0x00004000 //Has shields, borg can adapt
  20. #define NPCAI_GREET_ALLIES 0x00008000 //Say hi to nearby allies
  21. #define NPCAI_FORM_TELE_NAV 0x00010000 //Tells formation people to use nav info to get to
  22. #define NPCAI_ENROUTE_TO_HOMEWP 0x00020000 //Lets us know to run our lostenemyscript when we get to homeWp
  23. #define NPCAI_MATCHPLAYERWEAPON 0x00040000 //Match the player's weapon except when it changes during cinematics
  24. #define NPCAI_DIE_ON_IMPACT 0x00100000 //Next time you crashland, die!
  25. #define NPCAI_WALKING 0x00200000
  26. #define NPCAI_STOP_AT_LOS 0x00400000 //Stop Running When We Hit LOS
  27. #define NPCAI_NAV_THROUGH_BREAKABLES 0x00800000 //Navigation allows connections through breakable (func_glass, func_breakable or misc_model_breakable)
  28. #define NPCAI_KNEEL 0x01000000 //Kneel befor Zod
  29. #define NPCAI_FLY 0x02000000 //Fly, My Pretty!
  30. #define NPCAI_FLAMETHROW 0x04000000
  31. #define NPCAI_ROSH 0x08000000 //I am Rosh, when I'm hurt, drop to one knee and wait for Vil or Dasariah to heal me
  32. #define NPCAI_HEAL_ROSH 0x10000000 //Constantly look for NPC with NPC_type of rosh_dark, follow him, heal him if needbe
  33. #define NPCAI_JUMP 0x20000000 //Jump Now
  34. #define NPCAI_BOSS_CHARACTER 0x40000000 //Boss NPC flag for certain immunities/defenses
  35. #define NPCAI_NO_JEDI_DELAY 0x80000000 //Reborn/Jedi don't taunt enemy before attacking
  36. //Script flags
  37. #define SCF_CROUCHED 0x00000001 //Force ucmd.upmove to be -127
  38. #define SCF_WALKING 0x00000002 //Force BUTTON_WALKING to be pressed
  39. #define SCF_MORELIGHT 0x00000004 //NPC will have a minlight of 96
  40. #define SCF_LEAN_RIGHT 0x00000008 //Force rightmove+BUTTON_USE
  41. #define SCF_LEAN_LEFT 0x00000010 //Force leftmove+BUTTON_USE
  42. #define SCF_RUNNING 0x00000020 //Takes off walking button, overrides SCF_WALKING
  43. #define SCF_ALT_FIRE 0x00000040 //Force to use alt-fire when firing
  44. #define SCF_NO_RESPONSE 0x00000080 //NPC will not do generic responses to being used
  45. #define SCF_FFDEATH 0x00000100 //Just tells player_die to run the friendly fire deathscript
  46. #define SCF_NO_COMBAT_TALK 0x00000200 //NPC will not use their generic combat chatter stuff
  47. #define SCF_CHASE_ENEMIES 0x00000400 //NPC chase enemies - FIXME: right now this is synonymous with using combat points... should it be?
  48. #define SCF_LOOK_FOR_ENEMIES 0x00000800 //NPC be on the lookout for enemies
  49. #define SCF_FACE_MOVE_DIR 0x00001000 //NPC face direction it's moving - FIXME: not really implemented right now
  50. #define SCF_IGNORE_ALERTS 0x00002000 //NPC ignore alert events
  51. #define SCF_DONT_FIRE 0x00004000 //NPC won't shoot
  52. #define SCF_DONT_FLEE 0x00008000 //NPC never flees
  53. #define SCF_FORCED_MARCH 0x00010000 //NPC that the player must aim at to make him walk
  54. #define SCF_NO_GROUPS 0x00020000 //NPC cannot alert groups or be part of a group
  55. #define SCF_FIRE_WEAPON 0x00040000 //NPC will fire his (her) weapon
  56. #define SCF_NO_MIND_TRICK 0x00080000 //Not succeptible to mind tricks
  57. #define SCF_USE_CP_NEAREST 0x00100000 //Will use combat point close to it, not next to player or try and flank player
  58. #define SCF_NO_FORCE 0x00200000 //Not succeptible to force powers
  59. #define SCF_NO_FALLTODEATH 0x00400000 //NPC will not scream and tumble and fall to hit death over large drops
  60. #define SCF_NO_ACROBATICS 0x00800000 //Jedi won't jump, roll or cartwheel
  61. #define SCF_USE_SUBTITLES 0x01000000 //Regardless of subtitle setting, this NPC will display subtitles when it speaks lines
  62. #define SCF_NO_ALERT_TALK 0x02000000 //Will not say alert sounds, but still can be woken up by alerts
  63. #define SCF_NAV_CAN_FLY 0x04000000 //Navigation allows connections through air
  64. #define SCF_FLY_WITH_JET 0x08000000 //Must Fly With A Jet
  65. #define SCF_PILOT 0x10000000 //Can pilot a vehicle
  66. #define SCF_NAV_CAN_JUMP 0x20000000 //Can attempt to jump when blocked
  67. #define SCF_FIRE_WEAPON_NO_ANIM 0x40000000 //Fire weapon but don't play weapon firing anim
  68. #define SCF_SAFE_REMOVE 0x80000000 //Remove NPC when it's safe (when player isn't looking)
  69. //#ifdef __DEBUG
  70. //Debug flag definitions
  71. #define AID_IDLE 0x00000000 //Nothing is happening
  72. #define AID_ACQUIRED 0x00000001 //A target has been found
  73. #define AID_LOST 0x00000002 //Alert, but no target is in sight
  74. #define AID_CONFUSED 0x00000004 //Is unable to come up with a course of action
  75. #define AID_LOSTPATH 0x00000008 //Cannot make a valid movement due to lack of connections
  76. //#endif //__DEBUG
  77. //extern qboolean showWaypoints;
  78. typedef enum {VIS_UNKNOWN, VIS_NOT, VIS_PVS, VIS_360, VIS_FOV, VIS_SHOOT} visibility_t;
  79. typedef enum {SPOT_ORIGIN, SPOT_CHEST, SPOT_HEAD, SPOT_HEAD_LEAN, SPOT_WEAPON, SPOT_LEGS, SPOT_GROUND} spot_t;
  80. typedef enum //# lookMode_e
  81. {
  82. LM_ENT = 0,
  83. LM_INTEREST
  84. } lookMode_t;
  85. typedef enum //# jumpState_e
  86. {
  87. JS_WAITING = 0,
  88. JS_FACING,
  89. JS_CROUCHING,
  90. JS_JUMPING,
  91. JS_LANDING
  92. } jumpState_t;
  93. typedef enum
  94. {
  95. SEX_NEUTRAL = 0,
  96. SEX_MALE,
  97. SEX_FEMALE,
  98. SEX_SHEMALE//what the Hell, ya never know...
  99. } sexType_t;
  100. // !!!!!!!!!! LOADSAVE-affecting structure !!!!!!!!!!
  101. typedef struct gNPCstats_e
  102. {//Stats, loaded in, and can be set by scripts
  103. //AI
  104. int aggression; // "
  105. int aim; // "
  106. float earshot; // "
  107. int evasion; // "
  108. int hfov; // horizontal field of view
  109. int intelligence; // "
  110. int move; // "
  111. int reactions; // 1-5, higher is better
  112. float shootDistance; //Maximum range- overrides range set for weapon if nonzero
  113. int vfov; // vertical field of view
  114. float vigilance; // "
  115. float visrange; // "
  116. //Movement
  117. int runSpeed;
  118. int walkSpeed;
  119. float yawSpeed; // 1 - whatever, default is 50
  120. int health;
  121. int acceleration;
  122. //sex
  123. sexType_t sex; //male, female, etc.
  124. } gNPCstats_t;
  125. #define MAX_ENEMY_POS_LAG 2400
  126. #define ENEMY_POS_LAG_INTERVAL 100
  127. #define ENEMY_POS_LAG_STEPS (MAX_ENEMY_POS_LAG/ENEMY_POS_LAG_INTERVAL)
  128. // !!!!!!!!!! LOADSAVE-affecting structure !!!!!!!!!!
  129. typedef struct
  130. {
  131. //FIXME: Put in playerInfo or something
  132. int timeOfDeath; //FIXME do we really need both of these
  133. gentity_t *touchedByPlayer;
  134. visibility_t enemyLastVisibility;
  135. int aimTime;
  136. float desiredYaw;
  137. float desiredPitch;
  138. float lockedDesiredYaw;
  139. float lockedDesiredPitch;
  140. gentity_t *aimingBeam; // debugging aid
  141. vec3_t enemyLastSeenLocation;
  142. int enemyLastSeenTime;
  143. vec3_t enemyLastHeardLocation;
  144. int enemyLastHeardTime;
  145. int lastAlertID; //unique ID
  146. int eFlags;
  147. int aiFlags;
  148. int currentAmmo; // this sucks, need to find a better way
  149. int shotTime;
  150. int burstCount;
  151. int burstMin;
  152. int burstMean;
  153. int burstMax;
  154. int burstSpacing;
  155. int attackHold;
  156. int attackHoldTime;
  157. vec3_t shootAngles; //Angles to where bot is shooting - fixme: make he torso turn to reflect these
  158. //extra character info
  159. rank_t rank; //for pips
  160. //Behavior state info
  161. bState_t behaviorState; //determines what actions he should be doing
  162. bState_t defaultBehavior;//State bot will default to if none other set
  163. bState_t tempBehavior;//While valid, overrides other behavior
  164. qboolean ignorePain; //only play pain scripts when take pain
  165. int duckDebounceTime;//Keeps them ducked for a certain time
  166. int walkDebounceTime;
  167. int enemyCheckDebounceTime;
  168. int investigateDebounceTime;
  169. int investigateCount;
  170. vec3_t investigateGoal;
  171. int investigateSoundDebounceTime;
  172. int greetingDebounceTime;//when we can greet someone next
  173. gentity_t *eventOwner;
  174. //bState-specific fields
  175. gentity_t *coverTarg;
  176. jumpState_t jumpState;
  177. float followDist;
  178. // goal, navigation & pathfinding
  179. gentity_t *tempGoal; // used for locational goals (player's last seen/heard position)
  180. gentity_t *goalEntity;
  181. gentity_t *lastGoalEntity;
  182. gentity_t *eventualGoal;
  183. gentity_t *captureGoal; //Where we should try to capture
  184. gentity_t *defendEnt; //Who we're trying to protect
  185. gentity_t *greetEnt; //Who we're greeting
  186. int goalTime; //FIXME: This is never actually used
  187. qboolean straightToGoal; //move straight at navgoals
  188. float distToGoal;
  189. int navTime;
  190. int blockingEntNum;
  191. int blockedSpeechDebounceTime;
  192. int homeWp;
  193. int avoidSide;
  194. int leaderAvoidSide;
  195. int lastAvoidSteerSide;
  196. int lastAvoidSteerSideDebouncer;
  197. AIGroupInfo_t *group;
  198. int troop;
  199. vec3_t lastPathAngles; //So we know which way to face generally when we stop
  200. //stats
  201. gNPCstats_t stats;
  202. int aimErrorDebounceTime;
  203. float lastAimErrorYaw;
  204. float lastAimErrorPitch;
  205. vec3_t aimOfs;
  206. int currentAim;
  207. int currentAggression;
  208. //scriptflags
  209. int scriptFlags;//in b_local.h
  210. //moveInfo
  211. int desiredSpeed;
  212. int currentSpeed;
  213. char last_forwardmove;
  214. char last_rightmove;
  215. vec3_t lastClearOrigin;
  216. int shoveCount;
  217. int blockedDebounceTime;
  218. gentity_t* blockedEntity; // The entity That Causes The Current Blockage
  219. vec3_t blockedTargetPosition; // Where the actor was trying to get TO before blocked
  220. gentity_t* blockedTargetEntity; // Where the actor was trying to get TO before blocked
  221. //jump info
  222. vec3_t jumpDest; // Where The Actor Is Trying To Jump TO
  223. gentity_t* jumpTarget; // What Entity The Actor Is Trying To Jump TO
  224. float jumpMaxXYDist; // The Minimal Delta On The XY Plane Allowed To Jump To The Dest
  225. float jumpMazZDist;
  226. int jumpSide; // Which Side The Last Jump Occured On
  227. int jumpTime; // When The Last Jump Started
  228. int jumpBackupTime; // If Active, Then The Guy Should Backup Before Jumping
  229. int jumpNextCheckTime; // The Minimal Next Time To Check For A Jump
  230. //
  231. int combatPoint;//NPCs in bState BS_COMBAT_POINT will find their closest empty combat_point
  232. int lastFailedCombatPoint;//NPCs in bState BS_COMBAT_POINT will find their closest empty combat_point
  233. int movementSpeech; //what to say when you first successfully move
  234. float movementSpeechChance;//how likely you are to say it
  235. //Testing physics at 20fps
  236. int nextBStateThink;
  237. usercmd_t last_ucmd;
  238. //
  239. //JWEIER ADDITIONS START
  240. qboolean combatMove;
  241. int goalRadius;
  242. //FIXME: These may be redundant
  243. /*
  244. int weaponTime; //Time until refire is valid
  245. int jumpTime;
  246. */
  247. int pauseTime; //Time to stand still
  248. int standTime;
  249. int localState; //Tracking information local to entity
  250. int squadState; //Tracking information for team level interaction
  251. //JWEIER ADDITIONS END
  252. //
  253. int confusionTime; //Doesn't respond to alerts or pick up enemies (unless shot) until this time is up
  254. int charmedTime; //charmed to enemy team
  255. int controlledTime; //controlled by player
  256. int surrenderTime; //Hands up
  257. int kneelTime; //kneeling (for troopers)
  258. //Lagging enemy position - FIXME: seems awful wasteful...
  259. vec3_t enemyLaggedPos[ENEMY_POS_LAG_STEPS];
  260. gentity_t *watchTarget; //for BS_CINEMATIC, keeps facing this ent
  261. int ffireCount; //sigh... you'd think I'd be able to find a way to do this without having to use 3 int fields, but...
  262. int ffireDebounce;
  263. int ffireFadeDebounce;
  264. } gNPC_t;
  265. void G_SquadPathsInit(void);
  266. void NPC_InitGame( void );
  267. void G_LoadBoltOns( void );
  268. void Svcmd_NPC_f( void );
  269. /*
  270. void Bot_InitGame( void );
  271. void Bot_InitPreSpawn( void );
  272. void Bot_InitPostSpawn( void );
  273. void Bot_Shutdown( void );
  274. void Bot_Think( gentity_t *ent, int msec );
  275. void Bot_Connect( gentity_t *bot, char *botName );
  276. void Bot_Begin( gentity_t *bot );
  277. void Bot_Disconnect( gentity_t *bot );
  278. void Svcmd_Bot_f( void );
  279. void Nav_ItemSpawn( gentity_t *ent, int remaining );
  280. */
  281. //
  282. // This section should be moved to QFILES.H
  283. //
  284. /*
  285. #define NAVFILE_ID (('I')+('N'<<8)+('A'<<16)+('V'<<24))
  286. #define NAVFILE_VERSION 6
  287. typedef struct {
  288. unsigned id;
  289. unsigned version;
  290. unsigned checksum;
  291. unsigned surfaceCount;
  292. unsigned edgeCount;
  293. } navheader_t;
  294. #define MAX_SURFACES 4096
  295. #define NSF_PUSH 0x00000001
  296. #define NSF_WATERLEVEL1 0x00000002
  297. #define NSF_WATERLEVEL2 0x00000004
  298. #define NSF_WATER_NOAIR 0x00000008
  299. #define NSF_DUCK 0x00000010
  300. #define NSF_PAIN 0x00000020
  301. #define NSF_TELEPORTER 0x00000040
  302. #define NSF_PLATHIGH 0x00000080
  303. #define NSF_PLATLOW 0x00000100
  304. #define NSF_DOOR_FLOOR 0x00000200
  305. #define NSF_DOOR_SHOOT 0x00000400
  306. #define NSF_DOOR_BUTTON 0x00000800
  307. #define NSF_BUTTON 0x00001000
  308. typedef struct {
  309. vec3_t origin;
  310. vec2_t absmin;
  311. vec2_t absmax;
  312. int parm;
  313. unsigned flags;
  314. unsigned edgeCount;
  315. unsigned edgeIndex;
  316. } nsurface_t;
  317. #define NEF_DUCK 0x00000001
  318. #define NEF_JUMP 0x00000002
  319. #define NEF_HOLD 0x00000004
  320. #define NEF_WALK 0x00000008
  321. #define NEF_RUN 0x00000010
  322. #define NEF_NOAIRMOVE 0x00000020
  323. #define NEF_LEFTGROUND 0x00000040
  324. #define NEF_PLAT 0x00000080
  325. #define NEF_FALL1 0x00000100
  326. #define NEF_FALL2 0x00000200
  327. #define NEF_DOOR_SHOOT 0x00000400
  328. #define NEF_DOOR_BUTTON 0x00000800
  329. #define NEF_BUTTON 0x00001000
  330. typedef struct {
  331. vec3_t origin;
  332. vec2_t absmin; // region within this surface that is the portal to the other surface
  333. vec2_t absmax;
  334. int surfaceNum;
  335. unsigned flags; // jump, prerequisite button, will take falling damage, etc...
  336. float cost;
  337. int dirIndex;
  338. vec3_t endSpot;
  339. int parm;
  340. } nedge_t;
  341. */
  342. #endif