codemp/game/b_public.h

Go to the documentation of this file.
00001 #ifndef __B_PUBLIC_H__
00002 #define __B_PUBLIC_H__
00003 
00004 #include "ai.h"
00005 
00006 #define NPCAI_CHECK_WEAPON              0x00000001
00007 #define NPCAI_BURST_WEAPON              0x00000002
00008 #define NPCAI_MOVING                    0x00000004
00009 #define NPCAI_TOUCHED_GOAL              0x00000008
00010 #define NPCAI_PUSHED                    0x00000010
00011 #define NPCAI_NO_COLL_AVOID             0x00000020
00012 #define NPCAI_BLOCKED                   0x00000040
00013 #define NPCAI_OFF_PATH                  0x00000100
00014 #define NPCAI_IN_SQUADPOINT             0x00000200
00015 #define NPCAI_STRAIGHT_TO_DESTPOS       0x00000400
00016 #define NPCAI_NO_SLOWDOWN               0x00001000
00017 #define NPCAI_LOST                              0x00002000      //Can't nav to his goal
00018 #define NPCAI_SHIELDS                   0x00004000      //Has shields, borg can adapt
00019 #define NPCAI_GREET_ALLIES              0x00008000      //Say hi to nearby allies
00020 #define NPCAI_FORM_TELE_NAV             0x00010000      //Tells formation people to use nav info to get to 
00021 #define NPCAI_ENROUTE_TO_HOMEWP 0x00020000      //Lets us know to run our lostenemyscript when we get to homeWp
00022 #define NPCAI_MATCHPLAYERWEAPON 0x00040000      //Match the player's weapon except when it changes during cinematics
00023 #define NPCAI_DIE_ON_IMPACT             0x00100000      //Next time you crashland, die!
00024 #define NPCAI_CUSTOM_GRAVITY    0x00200000      //Don't use g_gravity, I fly!
00025 
00026 //Script flags
00027 #define SCF_CROUCHED            0x00000001      //Force ucmd.upmove to be -127
00028 #define SCF_WALKING                     0x00000002      //Force BUTTON_WALKING to be pressed
00029 #define SCF_MORELIGHT           0x00000004      //NPC will have a minlight of 96
00030 #define SCF_LEAN_RIGHT          0x00000008      //Force rightmove+BUTTON_USE
00031 #define SCF_LEAN_LEFT           0x00000010      //Force leftmove+BUTTON_USE
00032 #define SCF_RUNNING                     0x00000020      //Takes off walking button, overrides SCF_WALKING
00033 #define SCF_ALT_FIRE            0x00000040      //Force to use alt-fire when firing
00034 #define SCF_NO_RESPONSE         0x00000080      //NPC will not do generic responses to being used
00035 #define SCF_FFDEATH                     0x00000100      //Just tells player_die to run the friendly fire deathscript
00036 #define SCF_NO_COMBAT_TALK      0x00000200      //NPC will not use their generic combat chatter stuff
00037 #define SCF_CHASE_ENEMIES       0x00000400      //NPC chase enemies - FIXME: right now this is synonymous with using combat points... should it be?
00038 #define SCF_LOOK_FOR_ENEMIES    0x00000800      //NPC be on the lookout for enemies
00039 #define SCF_FACE_MOVE_DIR       0x00001000      //NPC face direction it's moving - FIXME: not really implemented right now
00040 #define SCF_IGNORE_ALERTS       0x00002000      //NPC ignore alert events
00041 #define SCF_DONT_FIRE           0x00004000      //NPC won't shoot
00042 #define SCF_DONT_FLEE           0x00008000      //NPC never flees
00043 #define SCF_FORCED_MARCH        0x00010000      //NPC that the player must aim at to make him walk
00044 #define SCF_NO_GROUPS           0x00020000      //NPC cannot alert groups or be part of a group
00045 #define SCF_FIRE_WEAPON         0x00040000      //NPC will fire his (her) weapon
00046 #define SCF_NO_MIND_TRICK       0x00080000      //Not succeptible to mind tricks
00047 #define SCF_USE_CP_NEAREST      0x00100000      //Will use combat point close to it, not next to player or try and flank player
00048 #define SCF_NO_FORCE            0x00200000      //Not succeptible to force powers
00049 #define SCF_NO_FALLTODEATH      0x00400000      //NPC will not scream and tumble and fall to hit death over large drops
00050 #define SCF_NO_ACROBATICS       0x00800000      //Jedi won't jump, roll or cartwheel
00051 #define SCF_USE_SUBTITLES       0x01000000      //Regardless of subtitle setting, this NPC will display subtitles when it speaks lines
00052 #define SCF_NO_ALERT_TALK       0x02000000      //Will not say alert sounds, but still can be woken up by alerts
00053 
00054 //#ifdef __DEBUG
00055 
00056 //Debug flag definitions
00057 
00058 #define AID_IDLE                0x00000000      //Nothing is happening
00059 #define AID_ACQUIRED    0x00000001      //A target has been found
00060 #define AID_LOST                0x00000002      //Alert, but no target is in sight
00061 #define AID_CONFUSED    0x00000004      //Is unable to come up with a course of action
00062 #define AID_LOSTPATH    0x00000008      //Cannot make a valid movement due to lack of connections
00063 
00064 //#endif //__DEBUG
00065 
00066 //extern qboolean showWaypoints;
00067 
00068 typedef enum {VIS_UNKNOWN, VIS_NOT, VIS_PVS, VIS_360, VIS_FOV, VIS_SHOOT} visibility_t;
00069 typedef enum {SPOT_ORIGIN, SPOT_CHEST, SPOT_HEAD, SPOT_HEAD_LEAN, SPOT_WEAPON, SPOT_LEGS, SPOT_GROUND} spot_t;
00070 
00071 typedef enum //# lookMode_e
00072 {
00073         LM_ENT = 0,
00074         LM_INTEREST
00075 } lookMode_t;
00076 
00077 typedef enum //# jumpState_e
00078 {
00079         JS_WAITING = 0,
00080         JS_FACING,
00081         JS_CROUCHING,
00082         JS_JUMPING,
00083         JS_LANDING
00084 } jumpState_t;
00085 
00086 typedef struct gNPCstats_e
00087 {//Stats, loaded in, and can be set by scripts
00088         //AI
00089         int             aggression;                     //                      "
00090         int             aim;                            //                      "
00091         float   earshot;                        //                      "
00092         int             evasion;                        //                      "
00093         int             hfov;                           // horizontal field of view
00094         int             intelligence;           //                      "
00095         int             move;                           //                      "
00096         int             reactions;                      // 1-5, higher is better
00097         float   shootDistance;          //Maximum range- overrides range set for weapon if nonzero
00098         int             vfov;                           // vertical field of view
00099         float   vigilance;                      //                      "
00100         float   visrange;                       //                      "
00101         //Movement
00102         int             runSpeed;
00103         int             walkSpeed;
00104         float   yawSpeed;                       // 1 - whatever, default is 50
00105         int             health;
00106         int             acceleration;
00107 } gNPCstats_t;
00108 
00109 // NOTE!!!  If you add any ptr fields into this structure could you please tell me so I can update the load/save code?
00110 //      so far the only things I've got to cope with are a bunch of gentity_t*'s, but tell me if any more get added -slc
00111 //
00112 
00113 #define MAX_ENEMY_POS_LAG       2400
00114 #define ENEMY_POS_LAG_INTERVAL  100
00115 #define ENEMY_POS_LAG_STEPS     (MAX_ENEMY_POS_LAG/ENEMY_POS_LAG_INTERVAL)
00116 typedef struct 
00117 {
00118         //FIXME: Put in playerInfo or something
00119         int                     timeOfDeath;                    //FIXME do we really need both of these
00120         gentity_t       *touchedByPlayer;
00121 
00122         visibility_t    enemyLastVisibility;
00123 
00124         int                     aimTime;
00125         float           desiredYaw;
00126         float           desiredPitch;
00127         float           lockedDesiredYaw;
00128         float           lockedDesiredPitch;
00129         gentity_t       *aimingBeam;            // debugging aid
00130 
00131         vec3_t          enemyLastSeenLocation;
00132         int                     enemyLastSeenTime;
00133         vec3_t          enemyLastHeardLocation;
00134         int                     enemyLastHeardTime;
00135         int                     lastAlertID;            //unique ID
00136 
00137         int                     eFlags;
00138         int                     aiFlags;
00139 
00140         int                     currentAmmo;            // this sucks, need to find a better way
00141         int                     shotTime;
00142         int                     burstCount;
00143         int                     burstMin;
00144         int                     burstMean;
00145         int                     burstMax;
00146         int                     burstSpacing;
00147         int                     attackHold;
00148         int                     attackHoldTime;
00149         vec3_t          shootAngles;            //Angles to where bot is shooting - fixme: make he torso turn to reflect these
00150 
00151         //extra character info
00152         rank_t          rank;           //for pips
00153 
00154         //Behavior state info
00155         bState_t        behaviorState;  //determines what actions he should be doing
00156         bState_t        defaultBehavior;//State bot will default to if none other set
00157         bState_t        tempBehavior;//While valid, overrides other behavior
00158 
00159         qboolean        ignorePain;             //only play pain scripts when take pain
00160 
00161         int                     duckDebounceTime;//Keeps them ducked for a certain time
00162         int                     walkDebounceTime;
00163         int                     enemyCheckDebounceTime;
00164         int                     investigateDebounceTime;
00165         int                     investigateCount;
00166         vec3_t          investigateGoal;
00167         int                     investigateSoundDebounceTime;
00168         int                     greetingDebounceTime;//when we can greet someone next
00169         gentity_t       *eventOwner;
00170         
00171         //bState-specific fields
00172         gentity_t       *coverTarg;
00173         jumpState_t     jumpState;
00174         float           followDist;
00175 
00176         // goal, navigation & pathfinding
00177         gentity_t       *tempGoal;                      // used for locational goals (player's last seen/heard position)
00178         gentity_t       *goalEntity;
00179         gentity_t       *lastGoalEntity;
00180         gentity_t       *eventualGoal;
00181         gentity_t       *captureGoal;           //Where we should try to capture
00182         gentity_t       *defendEnt;                     //Who we're trying to protect
00183         gentity_t       *greetEnt;                      //Who we're greeting
00184         int                     goalTime;       //FIXME: This is never actually used
00185         qboolean        straightToGoal; //move straight at navgoals
00186         float           distToGoal;
00187         int                     navTime;
00188         int                     blockingEntNum;
00189         int                     blockedSpeechDebounceTime;
00190         int                     lastSideStepSide;
00191         int                     sideStepHoldTime;
00192         int                     homeWp;
00193         AIGroupInfo_t   *group;
00194 
00195         vec3_t          lastPathAngles;         //So we know which way to face generally when we stop
00196 
00197         //stats
00198         gNPCstats_t     stats;
00199         int                     aimErrorDebounceTime;
00200         float           lastAimErrorYaw;
00201         float           lastAimErrorPitch;
00202         vec3_t          aimOfs;
00203         int                     currentAim;
00204         int                     currentAggression;
00205 
00206         //scriptflags
00207         int                     scriptFlags;//in b_local.h
00208 
00209         //moveInfo
00210         int                     desiredSpeed;
00211         int                     currentSpeed;
00212         char            last_forwardmove;
00213         char            last_rightmove;
00214         vec3_t          lastClearOrigin;
00215         int                     consecutiveBlockedMoves;
00216         int                     blockedDebounceTime;
00217         int                     shoveCount;
00218         vec3_t          blockedDest;
00219 
00220         //
00221         int                     combatPoint;//NPCs in bState BS_COMBAT_POINT will find their closest empty combat_point
00222         int                     lastFailedCombatPoint;//NPCs in bState BS_COMBAT_POINT will find their closest empty combat_point
00223         int                     movementSpeech; //what to say when you first successfully move
00224         float           movementSpeechChance;//how likely you are to say it
00225 
00226         //Testing physics at 20fps
00227         int                     nextBStateThink;
00228         usercmd_t       last_ucmd;
00229 
00230         //
00231         //JWEIER ADDITIONS START
00232 
00233         qboolean        combatMove;
00234         int                     goalRadius;
00235 
00236         //FIXME: These may be redundant
00237         
00238         /*
00239         int                     weaponTime;             //Time until refire is valid
00240         int                     jumpTime;
00241         */
00242         int                     pauseTime;              //Time to stand still
00243         int                     standTime;
00244 
00245         int                     localState;             //Tracking information local to entity
00246         int                     squadState;             //Tracking information for team level interaction
00247 
00248         //JWEIER ADDITIONS END
00249         //
00250 
00251         int                     confusionTime;  //Doesn't respond to alerts or pick up enemies (unless shot) until this time is up
00252         int                     charmedTime;    //charmed to enemy team
00253         int                     controlledTime; //controlled by player
00254         int                     surrenderTime;  //Hands up
00255 
00256         //Lagging enemy position - FIXME: seems awful wasteful...
00257         vec3_t          enemyLaggedPos[ENEMY_POS_LAG_STEPS];
00258 
00259         gentity_t       *watchTarget;   //for BS_CINEMATIC, keeps facing this ent
00260 
00261         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...
00262         int                     ffireDebounce;  
00263         int                     ffireFadeDebounce;
00264 } gNPC_t;
00265 
00266 void G_SquadPathsInit(void);
00267 void NPC_InitGame( void );
00268 void G_LoadBoltOns( void );
00269 void Svcmd_NPC_f( void );
00270 void NAV_DebugShowWaypoints (void);
00271 void NAV_DebugShowBoxes (void);
00272 void NAV_DebugShowSquadPaths (void);
00273 /*
00274 void Bot_InitGame( void );
00275 void Bot_InitPreSpawn( void );
00276 void Bot_InitPostSpawn( void );
00277 void Bot_Shutdown( void );
00278 void Bot_Think( gentity_t *ent, int msec );
00279 void Bot_Connect( gentity_t *bot, char *botName );
00280 void Bot_Begin( gentity_t *bot );
00281 void Bot_Disconnect( gentity_t *bot );
00282 void Svcmd_Bot_f( void );
00283 void Nav_ItemSpawn( gentity_t *ent, int remaining );
00284 */
00285 
00286 //
00287 // This section should be moved to QFILES.H
00288 //
00289 /*
00290 #define NAVFILE_ID                      (('I')+('N'<<8)+('A'<<16)+('V'<<24))
00291 #define NAVFILE_VERSION         6
00292 
00293 typedef struct {
00294         unsigned        id;
00295         unsigned        version;
00296         unsigned        checksum;
00297         unsigned        surfaceCount;
00298         unsigned        edgeCount;
00299 } navheader_t;
00300 
00301 
00302 #define MAX_SURFACES    4096
00303 
00304 #define NSF_PUSH                        0x00000001
00305 #define NSF_WATERLEVEL1         0x00000002
00306 #define NSF_WATERLEVEL2         0x00000004
00307 #define NSF_WATER_NOAIR         0x00000008
00308 #define NSF_DUCK                        0x00000010
00309 #define NSF_PAIN                        0x00000020
00310 #define NSF_TELEPORTER          0x00000040
00311 #define NSF_PLATHIGH            0x00000080
00312 #define NSF_PLATLOW                     0x00000100
00313 #define NSF_DOOR_FLOOR          0x00000200
00314 #define NSF_DOOR_SHOOT          0x00000400
00315 #define NSF_DOOR_BUTTON         0x00000800
00316 #define NSF_BUTTON                      0x00001000
00317 
00318 typedef struct {
00319         vec3_t          origin;
00320         vec2_t          absmin;
00321         vec2_t          absmax;
00322         int                     parm;
00323         unsigned        flags;
00324         unsigned        edgeCount;
00325         unsigned        edgeIndex;
00326 } nsurface_t;
00327 
00328 
00329 #define NEF_DUCK                        0x00000001
00330 #define NEF_JUMP                        0x00000002
00331 #define NEF_HOLD                        0x00000004
00332 #define NEF_WALK                        0x00000008
00333 #define NEF_RUN                         0x00000010
00334 #define NEF_NOAIRMOVE           0x00000020
00335 #define NEF_LEFTGROUND          0x00000040
00336 #define NEF_PLAT                        0x00000080
00337 #define NEF_FALL1                       0x00000100
00338 #define NEF_FALL2                       0x00000200
00339 #define NEF_DOOR_SHOOT          0x00000400
00340 #define NEF_DOOR_BUTTON         0x00000800
00341 #define NEF_BUTTON                      0x00001000
00342 
00343 typedef struct {
00344         vec3_t          origin;
00345         vec2_t          absmin;         // region within this surface that is the portal to the other surface
00346         vec2_t          absmax;
00347         int                     surfaceNum;
00348         unsigned        flags;          // jump, prerequisite button, will take falling damage, etc...
00349         float           cost;
00350         int                     dirIndex;
00351         vec3_t          endSpot;
00352         int                     parm;
00353 } nedge_t;
00354 */
00355 #endif