1 /******************************* 2 * B_Bot.h * 3 * Description: * 4 * Used with all b_* * 5 *******************************/ 6 7 #ifndef __B_BOT_H__ 8 #define __B_BOT_H__ 9 10 #include "c_cvars.h" 11 #include "tables.h" 12 #include "info.h" 13 #include "doomdef.h" 14 #include "d_ticcmd.h" 15 #include "r_defs.h" 16 #include "a_pickups.h" 17 #include "stats.h" 18 19 #define FORWARDWALK 0x1900 20 #define FORWARDRUN 0x3200 21 #define SIDEWALK 0x1800 22 #define SIDERUN 0x2800 23 24 #define BOT_VERSION 0.97 25 //Switches- 26 #define BOT_RELEASE_COMPILE //Define this when compiling a version that should be released. 27 28 #define NOCOLOR 11 29 #define MAXTHINGNODES 100 //Path stuff (paths created between items). 30 #define SPAWN_DELAY 80 //Used to determine how many tics there are between each bot spawn when bot's are being spawned in a row (like when entering a new map). 31 32 #define BOTFILENAME "bots.cfg" 33 34 #define MAX_TRAVERSE_DIST 100000000 //10 meters, used within b_func.c 35 #define AVOID_DIST 45000000 //Try avoid incoming missiles once they reached this close 36 #define SAFE_SELF_MISDIST (140*FRACUNIT) //Distance from self to target where it's safe to pull a rocket. 37 #define FRIEND_DIST 15000000 //To friend. 38 #define DARK_DIST 5000000 //Distance that bot can see enemies in the dark from. 39 #define WHATS_DARK 50 //light value thats classed as dark. 40 #define MAX_MONSTER_TARGET_DIST 50000000 //Too high can slow down the performance, see P_mobj.c 41 #define ENEMY_SCAN_FOV (120*ANGLE_1) 42 #define THINGTRYTICK 1000 43 #define MAXMOVEHEIGHT (32*FRACUNIT) //MAXSTEPMOVE but with jumping counted in. 44 #define GETINCOMBAT 35000000 //Max distance to item. if it's due to be icked up in a combat situation. 45 #define SHOOTFOV (60*ANGLE_1) 46 #define AFTERTICS (2*TICRATE) //Seconds that bot will be alert on an recent enemy. Ie not looking the other way 47 #define MAXROAM (4*TICRATE) //When this time is elapsed the bot will roam after something else. 48 //monster mod 49 #define MSPAWN_DELAY 20//Tics between each spawn. 50 #define MMAXSELECT 100 //Maximum number of monsters that can be selected at a time. 51 52 struct FCheckPosition; 53 54 struct botskill_t 55 { 56 int aiming; 57 int perfection; 58 int reaction; //How fast the bot will fire after seeing the player. 59 int isp; //Instincts of Self Preservation. Personality 60 }; 61 62 FArchive &operator<< (FArchive &arc, botskill_t &skill); 63 64 enum 65 { 66 BOTINUSE_No, 67 BOTINUSE_Waiting, 68 BOTINUSE_Yes, 69 }; 70 71 //Info about all bots in the bots.cfg 72 //Updated during each level start. 73 //Info given to bots when they're spawned. 74 struct botinfo_t 75 { 76 botinfo_t *next; 77 char *name; 78 char *info; 79 botskill_t skill; 80 int inuse; 81 int lastteam; 82 }; 83 84 //Used to keep all the globally needed variables in nice order. 85 class FCajunMaster 86 { 87 public: 88 ~FCajunMaster(); 89 90 void ClearPlayer (int playernum, bool keepTeam); 91 92 //(b_game.cpp) 93 void Main (); 94 void Init (); 95 void End(); 96 bool SpawnBot (const char *name, int color = NOCOLOR); 97 void TryAddBot (BYTE **stream, int player); 98 void RemoveAllBots (bool fromlist); 99 bool LoadBots (); 100 void ForgetBots (); 101 102 //(b_func.cpp) 103 void StartTravel (); 104 void FinishTravel (); 105 bool IsLeader (player_t *player); 106 void SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum); 107 fixed_t FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd); 108 bool SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y, FCheckPosition &tm); 109 110 //(b_move.cpp) 111 bool CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cmd); 112 bool IsDangerous (sector_t *sec); 113 114 TArray<FString> getspawned; //Array of bots (their names) which should be spawned when starting a game. 115 BYTE freeze:1; //Game in freeze mode. 116 BYTE changefreeze:1; //Game wants to change freeze mode. 117 int botnum; 118 botinfo_t *botinfo; 119 int spawn_tries; 120 int wanted_botnum; 121 TObjPtr<AActor> firstthing; 122 TObjPtr<AActor> body1; 123 TObjPtr<AActor> body2; 124 125 bool m_Thinking; 126 127 private: 128 //(b_game.cpp) 129 bool DoAddBot (BYTE *info, botskill_t skill); 130 131 protected: 132 bool ctf; 133 int t_join; 134 bool observer; //Consoleplayer is observer. 135 }; 136 137 class DBot : public DThinker 138 { 139 DECLARE_CLASS(DBot,DThinker) 140 HAS_OBJECT_POINTERS 141 public: 142 DBot (); 143 144 void Clear (); 145 void Serialize (FArchive &arc); 146 void Tick (); 147 148 //(b_think.cpp) 149 void WhatToGet (AActor *item); 150 151 //(b_func.cpp) 152 bool Check_LOS (AActor *to, angle_t vangle); 153 154 player_t *player; 155 angle_t angle; // The wanted angle that the bot try to get every tic. 156 // (used to get a smooth view movement) 157 TObjPtr<AActor> dest; // Move Destination. 158 TObjPtr<AActor> prev; // Previous move destination. 159 TObjPtr<AActor> enemy; // The dead meat. 160 TObjPtr<AActor> missile; // A threatening missile that needs to be avoided. 161 TObjPtr<AActor> mate; // Friend (used for grouping in teamplay or coop). 162 TObjPtr<AActor> last_mate; // If bots mate disappeared (not if died) that mate is 163 // pointed to by this. Allows bot to roam to it if 164 // necessary. 165 166 //Skills 167 struct botskill_t skill; 168 169 //Tickers 170 int t_active; // Open door, lower lift stuff, door must open and 171 // lift must go down before bot does anything 172 // radical like try a stuckmove 173 int t_respawn; 174 int t_strafe; 175 int t_react; 176 int t_fight; 177 int t_roam; 178 int t_rocket; 179 180 //Misc booleans 181 bool first_shot; // Used for reaction skill. 182 bool sleft; // If false, strafe is right. 183 bool allround; 184 bool increase; 185 186 fixed_t oldx; 187 fixed_t oldy; 188 189 private: 190 //(b_think.cpp) 191 void Think (); 192 void ThinkForMove (ticcmd_t *cmd); 193 void Set_enemy (); 194 195 //(b_func.cpp) 196 bool Reachable (AActor *target); 197 void Dofire (ticcmd_t *cmd); 198 AActor *Choose_Mate (); 199 AActor *Find_enemy (); 200 angle_t FireRox (AActor *enemy, ticcmd_t *cmd); 201 202 //(b_move.cpp) 203 void Roam (ticcmd_t *cmd); 204 bool Move (ticcmd_t *cmd); 205 bool TryWalk (ticcmd_t *cmd); 206 void NewChaseDir (ticcmd_t *cmd); 207 void TurnToAng (); 208 void Pitch (AActor *target); 209 }; 210 211 212 //Externs 213 extern FCajunMaster bglobal; 214 extern cycle_t BotThinkCycles, BotSupportCycles; 215 216 EXTERN_CVAR (Float, bot_flag_return_time) 217 EXTERN_CVAR (Int, bot_next_color) 218 EXTERN_CVAR (Bool, bot_allow_duds) 219 EXTERN_CVAR (Int, bot_maxcorpses) 220 EXTERN_CVAR (Bool, bot_observer) 221 EXTERN_CVAR (Bool, bot_watersplash) 222 EXTERN_CVAR (Bool, bot_chat) 223 224 #endif // __B_BOT_H__ 225