00001 #include "bg_saga.h"
00002
00003 #define DEFAULT_FORCEPOWERS "5-1-000000000000000000"
00004
00005
00006
00007 #ifdef _XBOX // No bot has more than 150 bytes of chat right now
00008 #define MAX_CHAT_BUFFER_SIZE 256
00009 #else
00010 #define MAX_CHAT_BUFFER_SIZE 8192
00011 #endif
00012 #define MAX_CHAT_LINE_SIZE 128
00013
00014 #define TABLE_BRANCH_DISTANCE 32
00015 #define MAX_NODETABLE_SIZE 16384
00016
00017 #define MAX_LOVED_ONES 4
00018 #define MAX_ATTACHMENT_NAME 64
00019
00020 #define MAX_FORCE_INFO_SIZE 2048
00021
00022 #define WPFLAG_JUMP 0x00000010 //jump when we hit this
00023 #define WPFLAG_DUCK 0x00000020 //duck while moving around here
00024 #define WPFLAG_NOVIS 0x00000400 //go here for a bit even with no visibility
00025 #define WPFLAG_SNIPEORCAMPSTAND 0x00000800 //a good position to snipe or camp - stand
00026 #define WPFLAG_WAITFORFUNC 0x00001000 //wait for a func brushent under this point before moving here
00027 #define WPFLAG_SNIPEORCAMP 0x00002000 //a good position to snipe or camp - crouch
00028 #define WPFLAG_ONEWAY_FWD 0x00004000 //can only go forward on the trial from here (e.g. went over a ledge)
00029 #define WPFLAG_ONEWAY_BACK 0x00008000 //can only go backward on the trail from here
00030 #define WPFLAG_GOALPOINT 0x00010000 //make it a goal to get here.. goal points will be decided by setting "weight" values
00031 #define WPFLAG_RED_FLAG 0x00020000 //red flag
00032 #define WPFLAG_BLUE_FLAG 0x00040000 //blue flag
00033 #define WPFLAG_SIEGE_REBELOBJ 0x00080000 //rebel siege objective
00034 #define WPFLAG_SIEGE_IMPERIALOBJ 0x00100000 //imperial siege objective
00035 #define WPFLAG_NOMOVEFUNC 0x00200000 //don't move over if a func is under
00036
00037 #define WPFLAG_CALCULATED 0x00400000 //don't calculate it again
00038 #define WPFLAG_NEVERONEWAY 0x00800000 //never flag it as one-way
00039
00040 #define LEVELFLAG_NOPOINTPREDICTION 1 //don't take waypoint beyond current into account when adjusting path view angles
00041 #define LEVELFLAG_IGNOREINFALLBACK 2 //ignore enemies when in a fallback navigation routine
00042 #define LEVELFLAG_IMUSTNTRUNAWAY 4 //don't be scared
00043
00044 #define WP_KEEP_FLAG_DIST 128
00045
00046 #define BWEAPONRANGE_MELEE 1
00047 #define BWEAPONRANGE_MID 2
00048 #define BWEAPONRANGE_LONG 3
00049 #define BWEAPONRANGE_SABER 4
00050
00051 #define MELEE_ATTACK_RANGE 256
00052 #define SABER_ATTACK_RANGE 128
00053 #define MAX_CHICKENWUSS_TIME 10000 //wait 10 secs between checking which run-away path to take
00054
00055 #define BOT_RUN_HEALTH 40
00056 #define BOT_WPTOUCH_DISTANCE 32
00057 #define ENEMY_FORGET_MS 10000
00058
00059
00060
00061 #define BOT_PLANT_DISTANCE 256 //plant if within this radius from the last spotted enemy position
00062 #define BOT_PLANT_INTERVAL 15000 //only plant once per 15 seconds at max
00063 #define BOT_PLANT_BLOW_DISTANCE 256 //blow det packs if enemy is within this radius and I am further away than the enemy
00064
00065 #define BOT_MAX_WEAPON_GATHER_TIME 1000 //spend a max of 1 second after spawn issuing orders to gather weapons before attacking enemy base
00066 #define BOT_MAX_WEAPON_CHASE_TIME 15000 //time to spend gathering the weapon before persuing the enemy base (in case it takes longer than expected)
00067
00068 #define BOT_MAX_WEAPON_CHASE_CTF 5000 //time to spend gathering the weapon before persuing the enemy base (in case it takes longer than expected) [ctf-only]
00069
00070 #define BOT_MIN_SIEGE_GOAL_SHOOT 1024
00071 #define BOT_MIN_SIEGE_GOAL_TRAVEL 128
00072
00073 #define BASE_GUARD_DISTANCE 256 //guarding the flag
00074 #define BASE_FLAGWAIT_DISTANCE 256 //has the enemy flag and is waiting in his own base for his flag to be returned
00075 #define BASE_GETENEMYFLAG_DISTANCE 256 //waiting around to get the enemy's flag
00076
00077 #define BOT_FLAG_GET_DISTANCE 256
00078
00079 #define BOT_SABER_THROW_RANGE 800
00080
00081 typedef enum
00082 {
00083 CTFSTATE_NONE,
00084 CTFSTATE_ATTACKER,
00085 CTFSTATE_DEFENDER,
00086 CTFSTATE_RETRIEVAL,
00087 CTFSTATE_GUARDCARRIER,
00088 CTFSTATE_GETFLAGHOME,
00089 CTFSTATE_MAXCTFSTATES
00090 } bot_ctf_state_t;
00091
00092 typedef enum
00093 {
00094 SIEGESTATE_NONE,
00095 SIEGESTATE_ATTACKER,
00096 SIEGESTATE_DEFENDER,
00097 SIEGESTATE_MAXSIEGESTATES
00098 } bot_siege_state_t;
00099
00100 typedef enum
00101 {
00102 TEAMPLAYSTATE_NONE,
00103 TEAMPLAYSTATE_FOLLOWING,
00104 TEAMPLAYSTATE_ASSISTING,
00105 TEAMPLAYSTATE_REGROUP,
00106 TEAMPLAYSTATE_MAXTPSTATES
00107 } bot_teamplay_state_t;
00108
00109 typedef struct botattachment_s
00110 {
00111 int level;
00112 char name[MAX_ATTACHMENT_NAME];
00113 } botattachment_t;
00114
00115 typedef struct nodeobject_s
00116 {
00117 vec3_t origin;
00118
00119 float weight;
00120 int flags;
00121 #ifdef _XBOX
00122 short neighbornum;
00123 short inuse;
00124 #else
00125 int neighbornum;
00126 int inuse;
00127 #endif
00128 } nodeobject_t;
00129
00130 typedef struct boteventtracker_s
00131 {
00132 int eventSequence;
00133 int events[MAX_PS_EVENTS];
00134 float eventTime;
00135 } boteventtracker_t;
00136
00137 typedef struct botskills_s
00138 {
00139 int reflex;
00140 float accuracy;
00141 float turnspeed;
00142 float turnspeed_combat;
00143 float maxturn;
00144 int perfectaim;
00145 } botskills_t;
00146
00147
00148 typedef struct bot_state_s
00149 {
00150 int inuse;
00151 int botthink_residual;
00152 int client;
00153 int entitynum;
00154 playerState_t cur_ps;
00155 usercmd_t lastucmd;
00156 bot_settings_t settings;
00157 float thinktime;
00158 vec3_t origin;
00159 vec3_t velocity;
00160 vec3_t eye;
00161 int setupcount;
00162 float ltime;
00163 float entergame_time;
00164 int ms;
00165 int gs;
00166 int ws;
00167 vec3_t viewangles;
00168 vec3_t ideal_viewangles;
00169 vec3_t viewanglespeed;
00170
00171
00172 gentity_t *currentEnemy;
00173 gentity_t *revengeEnemy;
00174
00175 gentity_t *squadLeader;
00176
00177 gentity_t *lastHurt;
00178 gentity_t *lastAttacked;
00179
00180 gentity_t *wantFlag;
00181
00182 gentity_t *touchGoal;
00183 gentity_t *shootGoal;
00184
00185 gentity_t *dangerousObject;
00186
00187 vec3_t staticFlagSpot;
00188
00189 int revengeHateLevel;
00190 int isSquadLeader;
00191
00192 int squadRegroupInterval;
00193 int squadCannotLead;
00194
00195 int lastDeadTime;
00196
00197 wpobject_t *wpCurrent;
00198 wpobject_t *wpDestination;
00199 wpobject_t *wpStoreDest;
00200 vec3_t goalAngles;
00201 vec3_t goalMovedir;
00202 vec3_t goalPosition;
00203
00204 vec3_t lastEnemySpotted;
00205 vec3_t hereWhenSpotted;
00206 int lastVisibleEnemyIndex;
00207 int hitSpotted;
00208
00209 int wpDirection;
00210
00211 float destinationGrabTime;
00212 float wpSeenTime;
00213 float wpTravelTime;
00214 float wpDestSwitchTime;
00215 float wpSwitchTime;
00216 float wpDestIgnoreTime;
00217
00218 float timeToReact;
00219
00220 float enemySeenTime;
00221
00222 float chickenWussCalculationTime;
00223
00224 float beStill;
00225 float duckTime;
00226 float jumpTime;
00227 float jumpHoldTime;
00228 float jumpPrep;
00229 float forceJumping;
00230 float jDelay;
00231
00232 float aimOffsetTime;
00233 float aimOffsetAmtYaw;
00234 float aimOffsetAmtPitch;
00235
00236 float frame_Waypoint_Len;
00237 int frame_Waypoint_Vis;
00238 float frame_Enemy_Len;
00239 int frame_Enemy_Vis;
00240
00241 int isCamper;
00242 float isCamping;
00243 wpobject_t *wpCamping;
00244 wpobject_t *wpCampingTo;
00245 qboolean campStanding;
00246
00247 int randomNavTime;
00248 int randomNav;
00249
00250 int saberSpecialist;
00251
00252 int canChat;
00253 int chatFrequency;
00254 char currentChat[MAX_CHAT_LINE_SIZE];
00255 float chatTime;
00256 float chatTime_stored;
00257 int doChat;
00258 int chatTeam;
00259 gentity_t *chatObject;
00260 gentity_t *chatAltObject;
00261
00262 float meleeStrafeTime;
00263 int meleeStrafeDir;
00264 float meleeStrafeDisable;
00265
00266 int altChargeTime;
00267
00268 float escapeDirTime;
00269
00270 float dontGoBack;
00271
00272 int doAttack;
00273 int doAltAttack;
00274
00275 int forceWeaponSelect;
00276 int virtualWeapon;
00277
00278 int plantTime;
00279 int plantDecided;
00280 int plantContinue;
00281 int plantKillEmAll;
00282
00283 int runningLikeASissy;
00284 int runningToEscapeThreat;
00285
00286
00287
00288
00289
00290 botskills_t skills;
00291
00292 botattachment_t loved[MAX_LOVED_ONES];
00293 int lovednum;
00294
00295 int loved_death_thresh;
00296
00297 int deathActivitiesDone;
00298
00299 float botWeaponWeights[WP_NUM_WEAPONS];
00300
00301 int ctfState;
00302
00303 int siegeState;
00304
00305 int teamplayState;
00306
00307 int jmState;
00308
00309 int state_Forced;
00310
00311 int saberDefending;
00312 int saberDefendDecideTime;
00313 int saberBFTime;
00314 int saberBTime;
00315 int saberSTime;
00316 int saberThrowTime;
00317
00318 qboolean saberPower;
00319 int saberPowerTime;
00320
00321 int botChallengingTime;
00322
00323 char forceinfo[MAX_FORCE_INFO_SIZE];
00324
00325 #ifndef FORCEJUMP_INSTANTMETHOD
00326 int forceJumpChargeTime;
00327 #endif
00328
00329 int doForcePush;
00330
00331 int noUseTime;
00332 qboolean doingFallback;
00333
00334 int iHaveNoIdeaWhereIAmGoing;
00335 vec3_t lastSignificantAreaChange;
00336 int lastSignificantChangeTime;
00337
00338 int forceMove_Forward;
00339 int forceMove_Right;
00340 int forceMove_Up;
00341
00342 } bot_state_t;
00343
00344 void *B_TempAlloc(int size);
00345 void B_TempFree(int size);
00346
00347 void *B_Alloc(int size);
00348 void B_Free(void *ptr);
00349
00350
00351 void BotResetState(bot_state_t *bs);
00352
00353 int NumBots(void);
00354
00355 void BotUtilizePersonality(bot_state_t *bs);
00356 int BotDoChat(bot_state_t *bs, char *section, int always);
00357 void StandardBotAI(bot_state_t *bs, float thinktime);
00358 void BotWaypointRender(void);
00359 int OrgVisibleBox(vec3_t org1, vec3_t mins, vec3_t maxs, vec3_t org2, int ignore);
00360 int BotIsAChickenWuss(bot_state_t *bs);
00361 int GetNearestVisibleWP(vec3_t org, int ignore);
00362 int GetBestIdleGoal(bot_state_t *bs);
00363
00364 char *ConcatArgs( int start );
00365
00366 extern vmCvar_t bot_forcepowers;
00367 extern vmCvar_t bot_forgimmick;
00368 extern vmCvar_t bot_honorableduelacceptance;
00369 #ifdef _DEBUG
00370 extern vmCvar_t bot_nogoals;
00371 extern vmCvar_t bot_debugmessages;
00372 #endif
00373
00374 extern vmCvar_t bot_attachments;
00375 extern vmCvar_t bot_camp;
00376
00377 extern vmCvar_t bot_wp_info;
00378 extern vmCvar_t bot_wp_edit;
00379 extern vmCvar_t bot_wp_clearweight;
00380 extern vmCvar_t bot_wp_distconnect;
00381 extern vmCvar_t bot_wp_visconnect;
00382
00383 extern wpobject_t *flagRed;
00384 extern wpobject_t *oFlagRed;
00385 extern wpobject_t *flagBlue;
00386 extern wpobject_t *oFlagBlue;
00387
00388 extern gentity_t *eFlagRed;
00389 extern gentity_t *eFlagBlue;
00390
00391 extern char gBotChatBuffer[MAX_CLIENTS][MAX_CHAT_BUFFER_SIZE];
00392 extern float gWPRenderTime;
00393 extern float gDeactivated;
00394 extern float gBotEdit;
00395 extern int gWPRenderedFrame;
00396
00397 #include "../namespace_begin.h"
00398 extern wpobject_t *gWPArray[MAX_WPARRAY_SIZE];
00399 extern int gWPNum;
00400 #include "../namespace_end.h"
00401
00402 extern int gLastPrintedIndex;
00403 #ifndef _XBOX
00404 extern nodeobject_t nodetable[MAX_NODETABLE_SIZE];
00405 #endif
00406 extern int nodenum;
00407
00408 extern int gLevelFlags;
00409
00410 extern float floattime;
00411 #define FloatTime() floattime