codemp/game/b_local.h

Go to the documentation of this file.
00001 //B_local.h
00002 //re-added by MCG
00003 #ifndef __B_LOCAL_H__
00004 #define __B_LOCAL_H__
00005 
00006 #include "g_local.h"
00007 #include "b_public.h"
00008 #include "say.h"
00009 
00010 #include "ai.h"
00011 
00012 #define AI_TIMERS 0//turn on to see print-outs of AI/nav timing
00013 //
00014 // Navigation susbsystem
00015 //
00016 
00017 #define NAVF_DUCK                       0x00000001
00018 #define NAVF_JUMP                       0x00000002
00019 #define NAVF_HOLD                       0x00000004
00020 #define NAVF_SLOW                       0x00000008
00021 
00022 #define DEBUG_LEVEL_DETAIL      4
00023 #define DEBUG_LEVEL_INFO        3
00024 #define DEBUG_LEVEL_WARNING     2
00025 #define DEBUG_LEVEL_ERROR       1
00026 #define DEBUG_LEVEL_NONE        0
00027 
00028 #define MAX_GOAL_REACHED_DIST_SQUARED   256//16 squared
00029 #define MIN_ANGLE_ERROR 0.01f
00030 
00031 #define MIN_ROCKET_DIST_SQUARED 16384//128*128
00032 //
00033 // NPC.cpp
00034 //
00035 // ai debug cvars
00036 void SetNPCGlobals( gentity_t *ent );
00037 void SaveNPCGlobals(void);
00038 void RestoreNPCGlobals(void);
00039 extern vmCvar_t         debugNPCAI;                     // used to print out debug info about the NPC AI
00040 extern vmCvar_t         debugNPCFreeze;         // set to disable NPC ai and temporarily freeze them in place
00041 extern vmCvar_t         debugNPCAimingBeam;
00042 extern vmCvar_t         debugBreak;
00043 extern vmCvar_t         debugNoRoam;
00044 extern vmCvar_t         d_JediAI;
00045 extern vmCvar_t         d_saberCombat;
00046 
00047 extern void NPC_Think ( gentity_t *self);
00048 
00049 //NPC_reactions.cpp
00050 extern void NPC_Pain(gentity_t *self, gentity_t *attacker, int damage);
00051 extern void NPC_Touch( gentity_t *self, gentity_t *other, trace_t *trace );
00052 extern void NPC_Use( gentity_t *self, gentity_t *other, gentity_t *activator );
00053 extern float NPC_GetPainChance( gentity_t *self, int damage );
00054 
00055 //
00056 // NPC_misc.cpp
00057 //
00058 extern void Debug_Printf( vmCvar_t *cv, int level, char *fmt, ... );
00059 extern void Debug_NPCPrintf( gentity_t *printNPC, vmCvar_t *cv, int debugLevel, char *fmt, ... );
00060 
00061 //MCG - Begin============================================================
00062 //NPC_ai variables - shared by NPC.cpp andf the following modules
00063 extern gentity_t        *NPC;
00064 extern gNPC_t           *NPCInfo;
00065 extern gclient_t        *client;
00066 extern usercmd_t        ucmd;
00067 extern visibility_t     enemyVisibility;
00068 
00069 //AI_Default
00070 extern qboolean NPC_CheckInvestigate( int alertEventNum );
00071 extern qboolean NPC_StandTrackAndShoot (gentity_t *NPC, qboolean canDuck);
00072 extern void NPC_BSIdle( void );
00073 extern void NPC_BSPointShoot(qboolean shoot);
00074 extern void NPC_BSStandGuard (void);
00075 extern void NPC_BSPatrol (void);
00076 extern void NPC_BSHuntAndKill (void);
00077 extern void NPC_BSStandAndShoot (void);
00078 extern void NPC_BSRunAndShoot (void);
00079 extern void NPC_BSWait( void );
00080 extern void NPC_BSDefault( void );
00081 
00082 //NPC_behavior
00083 extern void NPC_BSAdvanceFight (void);
00084 extern void NPC_BSInvestigate (void);
00085 extern void NPC_BSSleep( void );
00086 extern void NPC_BSFlee (void);
00087 extern void NPC_BSFollowLeader (void);
00088 extern void NPC_BSJump (void);
00089 extern void NPC_BSRemove (void);
00090 extern void NPC_BSSearch (void);
00091 extern void NPC_BSSearchStart (int      homeWp, bState_t bState);
00092 extern void NPC_BSWander (void);
00093 extern void NPC_BSFlee( void );
00094 extern void NPC_StartFlee( gentity_t *enemy, vec3_t dangerPoint, int dangerLevel, int fleeTimeMin, int fleeTimeMax );
00095 extern void G_StartFlee( gentity_t *self, gentity_t *enemy, vec3_t dangerPoint, int dangerLevel, int fleeTimeMin, int fleeTimeMax );
00096 
00097 //NPC_combat
00098 extern int ChooseBestWeapon( void );
00099 extern void NPC_ChangeWeapon( int newWeapon );
00100 extern void ShootThink( void );
00101 extern void WeaponThink( qboolean inCombat );
00102 extern qboolean HaveWeapon( int weapon );
00103 extern qboolean CanShoot ( gentity_t *ent, gentity_t *shooter );
00104 extern void NPC_CheckPossibleEnemy( gentity_t *other, visibility_t vis );
00105 extern gentity_t *NPC_PickEnemy (gentity_t *closestTo, int enemyTeam, qboolean checkVis, qboolean findPlayersFirst, qboolean findClosest);
00106 extern gentity_t *NPC_CheckEnemy (qboolean findNew, qboolean tooFarOk, qboolean setEnemy ); //setEnemy = qtrue
00107 extern qboolean NPC_CheckAttack (float scale);
00108 extern qboolean NPC_CheckDefend (float scale);
00109 extern qboolean NPC_CheckCanAttack (float attack_scale, qboolean stationary);
00110 extern int NPC_AttackDebounceForWeapon (void);
00111 extern qboolean EntIsGlass (gentity_t *check);
00112 extern qboolean ShotThroughGlass (trace_t *tr, gentity_t *target, vec3_t spot, int mask);
00113 extern qboolean ValidEnemy (gentity_t *ent);
00114 extern void G_ClearEnemy (gentity_t *self);
00115 extern gentity_t *NPC_PickAlly ( qboolean facingEachOther, float range, qboolean ignoreGroup, qboolean movingOnly );
00116 extern void NPC_LostEnemyDecideChase(void);
00117 extern float NPC_MaxDistSquaredForWeapon( void );
00118 extern qboolean NPC_EvaluateShot( int hit, qboolean glassOK );
00119 extern int NPC_ShotEntity( gentity_t *ent, vec3_t impactPos ); //impactedPos = NULL
00120 
00121 //NPC_formation
00122 extern qboolean NPC_SlideMoveToGoal (void);
00123 extern float NPC_FindClosestTeammate (gentity_t *self);
00124 extern void NPC_CalcClosestFormationSpot(gentity_t *self);
00125 extern void G_MaintainFormations (gentity_t *self);
00126 extern void NPC_BSFormation (void);
00127 extern void NPC_CreateFormation (gentity_t *self);
00128 extern void NPC_DropFormation (gentity_t *self);
00129 extern void NPC_ReorderFormation (gentity_t *self);
00130 extern void NPC_InsertIntoFormation (gentity_t *self);
00131 extern void NPC_DeleteFromFormation (gentity_t *self);
00132 
00133 #define COLLISION_RADIUS 32
00134 #define NUM_POSITIONS 30
00135 
00136 //NPC spawnflags
00137 #define SFB_SMALLHULL   1
00138 
00139 #define SFB_RIFLEMAN    2
00140 #define SFB_OLDBORG             2//Borg
00141 #define SFB_PHASER              4
00142 #define SFB_GUN                 4//Borg
00143 #define SFB_TRICORDER   8
00144 #define SFB_TASER               8//Borg
00145 #define SFB_DRILL               16//Borg
00146 
00147 #define SFB_CINEMATIC   32
00148 #define SFB_NOTSOLID    64
00149 #define SFB_STARTINSOLID 128
00150 
00151 //NPC_goal
00152 extern void SetGoal( gentity_t *goal, float rating );
00153 extern void NPC_SetGoal( gentity_t *goal, float rating );
00154 extern void NPC_ClearGoal( void );
00155 extern void NPC_ReachedGoal( void );
00156 extern qboolean ReachedGoal( gentity_t *goal );
00157 extern gentity_t *UpdateGoal( void );
00158 extern qboolean NPC_ClearPathToGoal(vec3_t dir, gentity_t *goal);
00159 extern qboolean NPC_MoveToGoal( qboolean tryStraight );
00160 
00161 //NPC_reactions
00162 
00163 //NPC_senses
00164 #define ALERT_CLEAR_TIME        200
00165 #define CHECK_PVS               1
00166 #define CHECK_360               2
00167 #define CHECK_FOV               4
00168 #define CHECK_SHOOT             8
00169 #define CHECK_VISRANGE  16
00170 extern qboolean CanSee ( gentity_t *ent );
00171 extern qboolean InFOV ( gentity_t *ent, gentity_t *from, int hFOV, int vFOV );
00172 extern qboolean InFOV2( vec3_t origin, gentity_t *from, int hFOV, int vFOV );
00173 extern qboolean InFOV3( vec3_t spot, vec3_t from, vec3_t fromAngles, int hFOV, int vFOV );
00174 extern visibility_t NPC_CheckVisibility ( gentity_t *ent, int flags );
00175 extern qboolean InVisrange ( gentity_t *ent );
00176 
00177 //NPC_sounds
00178 //extern void NPC_AngerSound(void);
00179 
00180 //NPC_spawn
00181 extern void NPC_Spawn ( gentity_t *ent, gentity_t *other, gentity_t *activator );
00182 
00183 //NPC_stats
00184 extern int NPC_ReactionTime ( void );
00185 extern qboolean NPC_ParseParms( const char *NPCName, gentity_t *NPC );
00186 extern void NPC_LoadParms( void );
00187 
00188 //NPC_utils
00189 extern int      teamNumbers[TEAM_NUM_TEAMS];
00190 extern int      teamStrength[TEAM_NUM_TEAMS];
00191 extern int      teamCounter[TEAM_NUM_TEAMS];
00192 extern void CalcEntitySpot ( const gentity_t *ent, const spot_t spot, vec3_t point );
00193 extern qboolean NPC_UpdateAngles ( qboolean doPitch, qboolean doYaw );
00194 extern void NPC_UpdateShootAngles (vec3_t angles, qboolean doPitch, qboolean doYaw );
00195 extern qboolean NPC_UpdateFiringAngles ( qboolean doPitch, qboolean doYaw );
00196 extern void SetTeamNumbers (void);
00197 extern qboolean G_ActivateBehavior (gentity_t *self, int bset );
00198 extern void NPC_AimWiggle( vec3_t enemy_org );
00199 extern void NPC_SetLookTarget( gentity_t *self, int entNum, int clearTime );
00200 
00201 //g_nav.cpp
00202 extern int NAV_FindClosestWaypointForEnt (gentity_t *ent, int targWp);
00203 extern qboolean NAV_CheckAhead( gentity_t *self, vec3_t end, trace_t *trace, int clipmask );
00204 
00205 //NPC_combat
00206 extern float IdealDistance ( gentity_t *self );
00207 
00208 //g_squad
00209 extern void NPC_SetSayState (gentity_t *self, gentity_t *to, int saying);
00210 
00211 //g_utils
00212 extern qboolean G_CheckInSolid (gentity_t *self, qboolean fix);
00213 
00214 //MCG - End============================================================
00215 
00216 // NPC.cpp
00217 extern void NPC_SetAnim(gentity_t *ent, int type, int anim, int priority);
00218 extern qboolean NPC_EnemyTooFar(gentity_t *enemy, float dist, qboolean toShoot);
00219 
00220 // ==================================================================
00221 
00222 //rww - special system for sync'ing bone angles between client and server.
00223 void NPC_SetBoneAngles(gentity_t *ent, char *bone, vec3_t angles);
00224 
00225 //rww - and another method of automatically managing surface status for the client and server at once
00226 void NPC_SetSurfaceOnOff(gentity_t *ent, const char *surfaceName, int surfaceFlags);
00227 
00228 extern qboolean NPC_ClearLOS( const vec3_t start, const vec3_t end );
00229 extern qboolean NPC_ClearLOS5( const vec3_t end );
00230 extern qboolean NPC_ClearLOS4( gentity_t *ent ) ;
00231 extern qboolean NPC_ClearLOS3( const vec3_t start, gentity_t *ent );
00232 extern qboolean NPC_ClearLOS2( gentity_t *ent, const vec3_t end );
00233 
00234 extern qboolean NPC_ClearShot( gentity_t *ent );
00235 
00236 extern int NPC_FindCombatPoint( const vec3_t position, const vec3_t avoidPosition, vec3_t enemyPosition, const int flags, const float avoidDist, const int ignorePoint ); //ignorePoint = -1
00237 
00238 
00239 extern qboolean NPC_ReserveCombatPoint( int combatPointID );
00240 extern qboolean NPC_FreeCombatPoint( int combatPointID, qboolean failed ); //failed = qfalse
00241 extern qboolean NPC_SetCombatPoint( int combatPointID );
00242 
00243 #define CP_ANY                  0                       //No flags
00244 #define CP_COVER                0x00000001      //The enemy cannot currently shoot this position
00245 #define CP_CLEAR                0x00000002      //This cover point has a clear shot to the enemy
00246 #define CP_FLEE                 0x00000004      //This cover point is marked as a flee point
00247 #define CP_DUCK                 0x00000008      //This cover point is marked as a duck point
00248 #define CP_NEAREST              0x00000010      //Find the nearest combat point
00249 #define CP_AVOID_ENEMY  0x00000020      //Avoid our enemy
00250 #define CP_INVESTIGATE  0x00000040      //A special point worth enemy investigation if searching
00251 #define CP_SQUAD                0x00000080      //Squad path
00252 #define CP_AVOID                0x00000100      //Avoid supplied position
00253 #define CP_APPROACH_ENEMY 0x00000200    //Try to get closer to enemy
00254 #define CP_CLOSEST              0x00000400      //Take the closest combatPoint to the enemy that's available
00255 #define CP_FLANK                0x00000800      //Pick a combatPoint behind the enemy
00256 #define CP_HAS_ROUTE    0x00001000      //Pick a combatPoint that we have a route to
00257 #define CP_SNIPE                0x00002000      //Pick a combatPoint that is marked as a sniper spot
00258 #define CP_SAFE                 0x00004000      //Pick a combatPoint that is not have dangerTime
00259 #define CP_HORZ_DIST_COLL 0x00008000    //Collect combat points within *horizontal* dist
00260 #define CP_NO_PVS               0x00010000      //A combat point out of the PVS of enemy pos
00261 #define CP_RETREAT              0x00020000      //Try to get farther from enemy
00262 
00263 #define CPF_NONE                0
00264 #define CPF_DUCK                0x00000001
00265 #define CPF_FLEE                0x00000002
00266 #define CPF_INVESTIGATE 0x00000004
00267 #define CPF_SQUAD               0x00000008
00268 #define CPF_LEAN                0x00000010
00269 #define CPF_SNIPE               0x00000020
00270 
00271 #define MAX_COMBAT_POINT_CHECK  32
00272 
00273 extern qboolean NPC_ValidEnemy( gentity_t *ent );
00274 extern qboolean NPC_CheckEnemyExt( qboolean checkAlerts ); //checkAlerts = qfalse
00275 extern qboolean NPC_FindPlayer( void );
00276 extern qboolean NPC_CheckCanAttackExt( void );
00277 
00278 extern int NPC_CheckAlertEvents( qboolean checkSight, qboolean checkSound, int ignoreAlert, qboolean mustHaveOwner, int minAlertLevel ); //ignoreAlert = -1, mustHaveOwner = qfalse, minAlertLevel = AEL_MINOR
00279 extern qboolean NPC_CheckForDanger( int alertEvent );
00280 extern void G_AlertTeam( gentity_t *victim, gentity_t *attacker, float radius, float soundDist );
00281 
00282 extern int NPC_FindSquadPoint( vec3_t position );
00283 
00284 extern void ClearPlayerAlertEvents( void );
00285 
00286 extern qboolean G_BoundsOverlap(const vec3_t mins1, const vec3_t maxs1, const vec3_t mins2, const vec3_t maxs2);
00287 extern qboolean NAV_HitNavGoal( vec3_t point, vec3_t mins, vec3_t maxs, vec3_t dest, int radius, qboolean flying );
00288 
00289 extern void NPC_SetMoveGoal( gentity_t *ent, vec3_t point, int radius, qboolean isNavGoal, int combatPoint, gentity_t *targetEnt ); //isNavGoal = qfalse, combatPoint = -1, targetEnt = NULL
00290 
00291 extern qboolean NAV_ClearPathToPoint(gentity_t *self, vec3_t pmins, vec3_t pmaxs, vec3_t point, int clipmask, int okToHitEnt );
00292 extern void NPC_ApplyWeaponFireDelay(void);
00293 
00294 //NPC_FaceXXX suite
00295 extern qboolean NPC_FacePosition( vec3_t position, qboolean doPitch ); //doPitch = qtrue
00296 extern qboolean NPC_FaceEntity( gentity_t *ent, qboolean doPitch ); //doPitch = qtrue
00297 extern qboolean NPC_FaceEnemy( qboolean doPitch ); //doPitch = qtrue
00298 
00299 //Skill level cvar
00300 extern vmCvar_t g_spskill;
00301 
00302 #define NIF_NONE                0x00000000
00303 #define NIF_FAILED              0x00000001      //failed to find a way to the goal
00304 #define NIF_MACRO_NAV   0x00000002      //using macro navigation
00305 #define NIF_COLLISION   0x00000004      //resolving collision with an entity
00306 #define NIF_BLOCKED             0x00000008      //blocked from moving
00307 
00308 /*
00309 -------------------------
00310 struct navInfo_s
00311 -------------------------
00312 */
00313 
00314 typedef struct navInfo_s
00315 {
00316         gentity_t       *blocker;
00317         vec3_t          direction;
00318         vec3_t          pathDirection;
00319         float           distance;
00320         trace_t         trace;
00321         int                     flags;
00322 } navInfo_t;
00323 
00324 extern int      NAV_MoveToGoal( gentity_t *self, navInfo_t *info );
00325 extern void NAV_GetLastMove( navInfo_t *info );
00326 extern qboolean NAV_AvoidCollision( gentity_t *self, gentity_t *goal, navInfo_t *info );
00327 
00328 
00329 #endif