1 /** 2 * @file 3 * @brief Various definess used by Crawl. 4 * 5 * A variety of miscellaneous constant values are found here. 6 **/ 7 8 #pragma once 9 10 #include <cstdint> 11 12 #include "macros.h" 13 14 // In this case, an x86 CPU will use x87 math for floating point calculations, 15 // which uses 80 bit intermediate results, andleads to difference from the 16 // (much more common, in 2019) SSE-based calculations. 17 // probably far from the only case where seeding isn't reliable... 18 #if defined(TARGET_CPU_X86) && !defined(__SSE__) 19 #define SEEDING_UNRELIABLE 20 #endif 21 22 // Minimum terminal size allowed. 23 #define MIN_COLS 79 24 #define MIN_LINES 24 25 26 #define ESCAPE '\x1b' // most ansi-friendly way I can think of defining this. 27 28 // there's got to be a better way... 29 #ifndef _LIBUNIX_IMPLEMENTATION 30 #else 31 #ifndef TRUE 32 #define TRUE 1 33 #endif 34 35 #ifndef FALSE 36 #define FALSE 0 37 #endif 38 #endif 39 40 // max size of inventory array {dlb}: 41 #define ENDOFPACK 52 42 43 // Max ghosts in a bones file. 44 const int MAX_GHOSTS = 127; 45 46 enum extra_monster_index_type 47 { 48 MAX_MONSTERS = 700, // max size of monster array {dlb} 49 ANON_FRIENDLY_MONSTER = MAX_MONSTERS,// unknown/dead ally, for actor blaming 50 YOU_FAULTLESS, // full xp but no penalty (reflection) 51 NON_MONSTER = 27000, // no monster 52 53 MHITNOT = NON_MONSTER, 54 MHITYOU, 55 }; 56 57 // number of monster attack specs 58 #define MAX_NUM_ATTACKS 4 59 60 // size of Pan monster sets 61 #define PAN_MONS_ALLOC 10 62 #define MAX_MONS_ALLOC 20 63 64 #define MAX_SUBTYPES 60 65 66 // max size of item list {dlb}: 67 #define MAX_ITEMS 2000 68 // non-item -- (ITEMS + 1) {dlb} 69 #define NON_ITEM 27000 70 #define ITEM_IN_INVENTORY (coord_def(-1, -1)) 71 #define ITEM_IN_MONSTER_INVENTORY (coord_def(-2, -2)) 72 #define ITEM_IN_SHOP 32767 73 // NON_ITEM + mindex + 1 is used as the item link for monster inventory; 74 // make sure we're not colliding with that. 75 COMPILE_CHECK(ITEM_IN_SHOP > NON_ITEM + MAX_MONSTERS); 76 77 #if NON_ITEM <= MAX_ITEMS 78 #error NON_ITEM must be > MAX_ITEMS 79 #endif 80 81 // max x-bound for level generation {dlb} 82 #define GXM 80 83 // max y-bound for level generation {dlb} 84 #define GYM 70 85 86 const int INFINITE_DISTANCE = 30000; 87 // max distance on a map 88 #define GDM 105 89 90 // this is the size of the border around the playing area (see in_bounds()) 91 #define BOUNDARY_BORDER 1 92 93 // This is the border that must be left around the map. I'm not sure why it's 94 // necessary, beyond hysterical raisins. 95 const int MAPGEN_BORDER = 2; 96 97 // Now some defines about the actual play area: 98 // Note: these boundaries are exclusive for the zone the player can move/dig, 99 // and are inclusive for the area that we display on the map. 100 // Note: that the right (bottom) boundary is one smaller here. 101 #define X_BOUND_1 (-1 + BOUNDARY_BORDER) 102 #define X_BOUND_2 (GXM - BOUNDARY_BORDER) 103 #define X_WIDTH (X_BOUND_2 - X_BOUND_1 + 1) 104 105 #define Y_BOUND_1 (-1 + BOUNDARY_BORDER) 106 #define Y_BOUND_2 (GYM - BOUNDARY_BORDER) 107 #define Y_WIDTH (Y_BOUND_2 - Y_BOUND_1 + 1) 108 109 // maximal LOS radius. 110 // XXX: uses of this should be replaced depending on the intended behaviour, 111 // with LOS_DEFAULT_RANGE or LOS_MAX_RANGE or possibly you.current_vision 112 #define LOS_RADIUS 8 113 // LOS radius for 'normal' characters 114 #define LOS_DEFAULT_RANGE 7 115 116 // maximal horizontal or vertical LOS range: 117 // a quadrant needs to fit inside an 2D array with 118 // 0 <= x, y <= LOS_MAX_RANGE 119 #define LOS_MAX_RANGE LOS_RADIUS 120 #define ENV_SHOW_OFFSET LOS_MAX_RANGE 121 #define ENV_SHOW_DIAMETER (ENV_SHOW_OFFSET * 2 + 1) 122 123 #define VIEW_BASE_WIDTH 33 124 #define VIEW_MIN_WIDTH ENV_SHOW_DIAMETER 125 #define VIEW_MIN_HEIGHT ENV_SHOW_DIAMETER 126 #define MSG_MIN_HEIGHT 5 127 128 // max shops randomly generated in a level. 129 // changing this affects the total number of shops in a game 130 #define MAX_RANDOM_SHOPS 5 131 132 // range of overflow temples 133 #define MIN_OVERFLOW_LEVEL 3 134 #define MAX_OVERFLOW_LEVEL 10 135 136 #define MAX_BRANCH_DEPTH 27 137 COMPILE_CHECK(MAX_BRANCH_DEPTH < 256); // 8 bits 138 139 // This value is used to make test_hit checks always succeed 140 #define AUTOMATIC_HIT 1500 141 142 const int MAX_SKILL_LEVEL = 27; 143 const int MAX_EXP_TOTAL = 8999999; 144 const int EXERCISE_QUEUE_SIZE = 100; 145 146 const int MIN_HIT_MISS_PERCENTAGE = 5; 147 148 const int BASELINE_DELAY = 10; 149 const int INVIS_CONTAM_PER_TURN = 30; 150 151 const int ICEMAIL_MAX = 8; 152 const int ICEMAIL_TIME = 30 * BASELINE_DELAY; 153 154 // This value is used to mark immune levels of WL 155 const int WILL_INVULN = 5000; 156 157 // This is the damage amount used to signal insta-death 158 const int INSTANT_DEATH = -9999; 159 160 // Maximum enchantment on weapons/secondary armours 161 // Note: use armour_max_enchant(item) to get the correct limit for item 162 const int MAX_WPN_ENCHANT = 9; 163 const int MAX_SEC_ENCHANT = 2; 164 165 // formula for MP from a potion of magic 166 #define POT_MAGIC_MP (10 + random2avg(28, 3)) 167 168 const int MAX_KNOWN_SPELLS = 21; 169 170 const int INVALID_ABSDEPTH = -1000; 171 172 const int UNUSABLE_SKILL = -99; 173 174 //#define DEBUG_MIMIC 175 #ifdef DEBUG_MIMIC 176 #define FEATURE_MIMIC_CHANCE 1 177 #else 178 #define FEATURE_MIMIC_CHANCE 100 179 #endif 180 181 const int AGILITY_BONUS = 5; 182 183 #define POLAR_VORTEX_RADIUS 5 184 185 #define VAULTS_ENTRY_RUNES 1 186 #define ZOT_ENTRY_RUNES 3 187 #define ZIG_ENTRY_RUNES 2 188 189 // Size of unique_items in player class 190 #define MAX_UNRANDARTS 150 191 192 // Haste/slow boost. 193 #define haste_mul(x) div_rand_round((x) * 3, 2) 194 #define haste_div(x) div_rand_round((x) * 2, 3) 195 #define berserk_mul(x) div_rand_round((x) * 3, 2) 196 #define berserk_div(x) div_rand_round((x) * 2, 3) 197 198 #define MAX_MONSTER_HP 10000 199 200 // colours, such pretty colours ... 201 // The order is important (IRGB bit patterns). 202 enum COLOURS 203 { 204 COLOUR_INHERIT = -1, 205 BLACK, 206 COLOUR_UNDEF = BLACK, 207 BLUE, 208 GREEN, 209 CYAN, 210 RED, 211 MAGENTA, 212 BROWN, 213 LIGHTGRAY, 214 LIGHTGREY = LIGHTGRAY, 215 DARKGRAY, 216 DARKGREY = DARKGRAY, 217 LIGHTBLUE, 218 LIGHTGREEN, 219 LIGHTCYAN, 220 LIGHTRED, 221 LIGHTMAGENTA, 222 YELLOW, 223 WHITE, 224 NUM_TERM_COLOURS 225 }; 226 227 // Many, MANY places currently hard-code this to 8 bits, but we need to 228 // expand it. Please use colour_t in new code. 229 typedef uint8_t colour_t; 230 231 // Colour options... these are used as bit flags along with the colour 232 // value in the low byte. 233 234 // This is used to signal curses (which has seven base colours) to 235 // try to get a brighter version using recommissioned attribute flags. 236 #define COLFLAG_CURSES_BRIGHTEN 0x0008 237 238 #define COLFLAG_FRIENDLY_MONSTER 0x0100 239 #define COLFLAG_NEUTRAL_MONSTER 0x0200 240 #define COLFLAG_WILLSTAB 0x0400 241 #define COLFLAG_MAYSTAB 0x0800 242 #define COLFLAG_ITEM_HEAP 0x1000 243 #define COLFLAG_FEATURE_ITEM 0x2000 244 #define COLFLAG_TRAP_ITEM 0x4000 245 #define COLFLAG_REVERSE 0x8000 246 #define COLFLAG_MASK 0xFF00 247 248 enum CHAR_ATTRIBUTES 249 { 250 CHATTR_NORMAL, /* 0 */ 251 CHATTR_STANDOUT, 252 CHATTR_BOLD, 253 CHATTR_BLINK, 254 CHATTR_UNDERLINE, 255 CHATTR_REVERSE, /* 5 */ 256 CHATTR_DIM, 257 CHATTR_HILITE, 258 259 CHATTR_ATTRMASK = 0xF, /* 15 (well, obviously) */ 260 261 CHATTR_COLMASK = 0xF00, // Mask with this to get extra colour info. 262 }; 263 264 #define PDESCS(colour) (colour) 265 #define PDESCQ(qualifier, colour) (((qualifier) * PDC_NCOLOURS) + (colour)) 266 267 #define PCOLOUR(desc) ((desc) % PDC_NCOLOURS) 268 #define PQUAL(desc) ((desc) / PDC_NCOLOURS) 269 270 // Convert capital letters into mystic numbers representing 271 // CTRL sequences. This is a macro because a lot of the type 272 // it wants to be used in case labels. 273 #define CONTROL(xxx) ((xxx) - 'A' + 1) 274 #define UNCONTROL(xxx) ((xxx) + 'A' - 1) 275 276 #define ARRAYSZ(x) (sizeof(x) / sizeof(x[0])) 277 #define RANDOM_ELEMENT(x) (x[random2(ARRAYSZ(x))]) 278 279 const char * const MONSTER_HIT_DICE = "monster-hit-dice"; 280 const char * const CORPSE_HEADS = "monster-number"; 281 const char * const CORPSE_NEVER_DECAYS = "corpse-no-decay"; 282 const char * const MONSTER_MID = "monster-mid"; 283 284 const char * const NEUTRAL_BRIBE_KEY = "gozag_bribed"; 285 const char * const FRIENDLY_BRIBE_KEY = "gozag_permabribed"; 286 287 const char * const THUNDERBOLT_CHARGES_KEY = "thunderbolt_charges"; 288 const char * const THUNDERBOLT_LAST_KEY = "thunderbolt_last"; 289 const char * const THUNDERBOLT_AIM_KEY = "thunderbolt_aim"; 290 291 // Synthetic keys: 292 #define KEY_MACRO_MORE_PROTECT -10 293 #define KEY_MACRO_DISABLE_MORE -1 294 #define KEY_MACRO_ENABLE_MORE -2 295 296 // cgotoxy regions 297 enum GotoRegion 298 { 299 GOTO_CRT, // cprintf > crt 300 GOTO_MSG, // cprintf > message 301 GOTO_STAT, // cprintf > character status 302 GOTO_DNGN, // cprintf > dungeon screen 303 GOTO_MLIST,// cprintf > monster list 304 }; 305 306 // Mouse modes (for tiles) 307 enum mouse_mode 308 { 309 MOUSE_MODE_NORMAL, 310 MOUSE_MODE_COMMAND, 311 MOUSE_MODE_TARGET, 312 MOUSE_MODE_TARGET_DIR, 313 MOUSE_MODE_TARGET_PATH, 314 MOUSE_MODE_MORE, 315 MOUSE_MODE_MACRO, 316 MOUSE_MODE_PROMPT, 317 MOUSE_MODE_YESNO, 318 MOUSE_MODE_MAX, 319 }; 320 321 const int DEFAULT_VIEW_DELAY = 600; 322 323 #define PI 3.14159265359f 324 325 #ifdef __ANDROID__ 326 #define ANDROID_ASSETS "ANDROID_ASSETS" 327 #endif 328