375 lines
6.5 KiB
C
375 lines
6.5 KiB
C
|
#ifndef __DEFS_H
|
||
|
#define __DEFS_H
|
||
|
|
||
|
// MACROS
|
||
|
#define MAXOF(a,b) (a > b ? a : b)
|
||
|
|
||
|
// save/load
|
||
|
#define MAPDIR "data/maps"
|
||
|
#define SAVEDIR "data/save"
|
||
|
|
||
|
// SPECIAL NUMBERS/CONSTANTS
|
||
|
#define UNLIMITED (-9876)
|
||
|
#define ALL (-9875)
|
||
|
#define NA (-9874)
|
||
|
|
||
|
|
||
|
// STRINGS
|
||
|
#define BUFLENSMALL 64
|
||
|
#define BUFLEN 128
|
||
|
#define HUGEBUFLEN 1024
|
||
|
|
||
|
|
||
|
#define MORESTRING "--More--"
|
||
|
|
||
|
|
||
|
// LIMITS
|
||
|
|
||
|
|
||
|
#define SCREENW 80
|
||
|
#define SCREENH 24
|
||
|
|
||
|
#define MAXPILEOBS 52
|
||
|
|
||
|
#define MAXRANDOMOBCANDIDATES 100
|
||
|
|
||
|
#define MAX_MAPW 80
|
||
|
#define MAX_MAPH 50
|
||
|
//#define MAX_MAPROOMS 10
|
||
|
|
||
|
#define MIN_ROOMH 4
|
||
|
#define MIN_ROOMW 4
|
||
|
#define MAX_ROOMW (MAX_MAPW / 5)
|
||
|
#define MAX_ROOMH (MAX_MAPH / 5)
|
||
|
|
||
|
#define MAXDIR_ORTH 4
|
||
|
#define MAXDIR_COMPASS 8
|
||
|
|
||
|
// MAP BUILDING
|
||
|
#define DEF_TURNPCT 40
|
||
|
#define DEF_SPARSENESS 14
|
||
|
//#define DEF_SPARSENESS 0
|
||
|
#define DEF_LOOPPCT 70
|
||
|
//#define DEF_LOOPPCT 0
|
||
|
#define MINROOMS 15
|
||
|
#define MAXROOMS 25
|
||
|
#define DEF_WINDOWPCT 5
|
||
|
|
||
|
//
|
||
|
#define ANIMDELAY (1000000 / 100) // 1/100 of a second
|
||
|
|
||
|
// CONTROLLERS
|
||
|
#define C_AI 0
|
||
|
#define C_PLAYER 1
|
||
|
|
||
|
// speed settings (lower is faster)
|
||
|
#define SPEED_ATTACK 10
|
||
|
#define SPEED_DEAD 50
|
||
|
#define SPEED_MOVE 10
|
||
|
#define SPEED_DROP 5
|
||
|
#define SPEED_PICKUP 5
|
||
|
#define SPEED_THROW 10
|
||
|
#define SPEED_WAIT 10
|
||
|
|
||
|
|
||
|
// DIRECTION TYPES
|
||
|
#define DT_ORTH 0
|
||
|
#define DT_COMPASS 1
|
||
|
|
||
|
// DIRECTIONS
|
||
|
|
||
|
|
||
|
#define D_NONE -1
|
||
|
#define D_UNKNOWN -2
|
||
|
|
||
|
// Orthogonal directions
|
||
|
#define D_N 0
|
||
|
#define D_E 1
|
||
|
#define D_S 2
|
||
|
#define D_W 3
|
||
|
|
||
|
// Compass directions
|
||
|
#define DC_N 4
|
||
|
#define DC_NE 5
|
||
|
#define DC_E 6
|
||
|
#define DC_SE 7
|
||
|
#define DC_S 8
|
||
|
#define DC_SW 9
|
||
|
#define DC_W 10
|
||
|
#define DC_NW 11
|
||
|
|
||
|
|
||
|
|
||
|
// Cell types
|
||
|
#define CT_WALL 0
|
||
|
#define CT_ROOMWALL 1
|
||
|
#define CT_CORRIDOR 2
|
||
|
#define CT_ROOM 3
|
||
|
#define CT_DOOROPEN 4
|
||
|
#define CT_DOORCLOSED 5
|
||
|
#define CT_LOOPCORRIDOR 6
|
||
|
|
||
|
// Object Classes
|
||
|
enum OBCLASS {
|
||
|
OC_MONEY,
|
||
|
OC_WEAPON,
|
||
|
OC_ARMOUR,
|
||
|
OC_SCROLL,
|
||
|
OC_POTION,
|
||
|
OC_FOOD,
|
||
|
OC_ROCK,
|
||
|
OC_MISC,
|
||
|
OC_NULL = -999
|
||
|
};
|
||
|
|
||
|
enum BLESSTYPE {
|
||
|
B_UNCURSED = 0,
|
||
|
B_BLESSED = 1,
|
||
|
B_CURSED = -1
|
||
|
};
|
||
|
|
||
|
enum HABITAT {
|
||
|
H_DUNGEON = 1,
|
||
|
H_ALL = 999
|
||
|
};
|
||
|
|
||
|
enum RARITY {
|
||
|
RR_NEVER = 6,
|
||
|
RR_VERYRARE = 5,
|
||
|
RR_RARE = 4,
|
||
|
RR_UNCOMMON = 3,
|
||
|
RR_COMMON = 2,
|
||
|
RR_FREQUENT = 1,
|
||
|
};
|
||
|
|
||
|
|
||
|
enum RACE {
|
||
|
R_BAT,
|
||
|
R_GIANTFLY,
|
||
|
R_GIANTBLOWFLY,
|
||
|
R_HUMAN,
|
||
|
R_GOBLIN,
|
||
|
};
|
||
|
|
||
|
// Object Materials
|
||
|
enum MATERIAL {
|
||
|
MT_STONE,
|
||
|
MT_FIRE,
|
||
|
MT_PLASTIC,
|
||
|
MT_METAL,
|
||
|
MT_FLESH,
|
||
|
MT_WOOD,
|
||
|
MT_GOLD
|
||
|
};
|
||
|
|
||
|
// Object Types
|
||
|
enum OBTYPE {
|
||
|
// rocks
|
||
|
OT_GOLD,
|
||
|
OT_STONE,
|
||
|
// corpses
|
||
|
OT_CORPSEHUMAN,
|
||
|
OT_CORPSEGOBLIN,
|
||
|
OT_CORPSEBAT,
|
||
|
OT_CORPSEFLY,
|
||
|
};
|
||
|
|
||
|
enum FLAG {
|
||
|
// object flags
|
||
|
F_STACKABLE, // can stack multiple objects togethr
|
||
|
F_NO_PLURAL, // this obname doesn't need an 's' for plurals (eg. gold, money)
|
||
|
F_NO_A, // this obname doesn't need to start with 'a' for singular (eg. gold)
|
||
|
F_EDIBLE, // you can eat this. val2 = nutrition
|
||
|
// lifeform flags
|
||
|
F_CORPSETYPE, // text field specifies what corpse obtype to leave
|
||
|
F_FLYING, // lf is flying
|
||
|
F_HOSTILE, // lf will attack anything the player if in sight
|
||
|
F_NODEATHANNOUNCE, // don't say 'the xx dies' if this lf dies
|
||
|
F_TARGET, // lf will attack this lf id
|
||
|
F_ATTACKSPEED, // override default attack speed
|
||
|
F_MOVESPEED, // override default move speed
|
||
|
F_RARITY, // val[0] = habitat, val[1] = rarity
|
||
|
F_NUMAPPEAR, // when randomly appearing, can have > 1. val[0] = min, val[1] = max
|
||
|
//
|
||
|
F_NULL = -1
|
||
|
};
|
||
|
|
||
|
|
||
|
// probabilities
|
||
|
//#define CH_DEADENDOB 35
|
||
|
//#define CH_EMPTYCELLOB 3
|
||
|
#define CH_PILLAR 5
|
||
|
|
||
|
// Booleans
|
||
|
#define B_FALSE (0)
|
||
|
#define B_TRUE (-1)
|
||
|
|
||
|
#define B_NOSTACK (0)
|
||
|
#define B_STACK (-1)
|
||
|
#define B_STACKOK (-1)
|
||
|
|
||
|
#define NOOWNER (NULL)
|
||
|
#define NOLOC (NULL)
|
||
|
|
||
|
#define B_NOTSOLID (0)
|
||
|
#define B_EMPTY (0)
|
||
|
#define B_SOLID (-1)
|
||
|
|
||
|
#define B_OPAQUE (0)
|
||
|
#define B_TRANSPARENT (-1)
|
||
|
#define B_TRANS (-1)
|
||
|
|
||
|
|
||
|
// errors
|
||
|
enum ERROR {
|
||
|
E_OK = 0,
|
||
|
E_WALLINWAY = 1,
|
||
|
E_LFINWAY = 2,
|
||
|
E_NOSPACE = 3
|
||
|
};
|
||
|
|
||
|
typedef struct map_s {
|
||
|
int id;
|
||
|
char *name; // name of this map
|
||
|
enum HABITAT habitat; // eg. dungeon, forest, etc
|
||
|
unsigned int seed;
|
||
|
int w,h; // width/height of this map
|
||
|
struct cell_s *cell[MAX_MAPW*MAX_MAPH]; // list of cells in this map
|
||
|
int nextmap[MAXDIR_ORTH]; // which map is in each direction
|
||
|
|
||
|
long nextlfid;
|
||
|
struct lifeform_s *lf,*lastlf;
|
||
|
|
||
|
struct map_s *next, *prev;
|
||
|
} map_t; //////////////// remember to modify save/load for new props!!
|
||
|
|
||
|
typedef struct cell_s {
|
||
|
map_t *map; // pointer back to map
|
||
|
int x,y; // map coords
|
||
|
int roomid;
|
||
|
struct celltype_s *type;
|
||
|
struct obpile_s *obpile;
|
||
|
|
||
|
// lifeform pile
|
||
|
struct lifeform_s *lf;
|
||
|
// known to player?
|
||
|
int known;
|
||
|
|
||
|
// FOR CONSTRUCTION
|
||
|
int visited;
|
||
|
} cell_t;
|
||
|
|
||
|
typedef struct celltype_s {
|
||
|
int id; // eg. dungeonfloor, wall, door
|
||
|
char glyph; // how to display it
|
||
|
int solid; // can you walk through it?
|
||
|
int transparent; // can you see through it?
|
||
|
struct celltype_s *next, *prev;
|
||
|
} celltype_t;
|
||
|
|
||
|
typedef struct race_s {
|
||
|
enum RACE id;
|
||
|
char *name;
|
||
|
char glyph;
|
||
|
struct flagpile_s *flags;
|
||
|
// speed modifiers
|
||
|
// hit dice
|
||
|
struct race_s *next, *prev;
|
||
|
} race_t;
|
||
|
|
||
|
typedef struct lifeform_s {
|
||
|
int id;
|
||
|
int controller;
|
||
|
struct race_s *race;
|
||
|
int hp,maxhp;
|
||
|
int alive;
|
||
|
char *lastdam;
|
||
|
|
||
|
int timespent;
|
||
|
int sorted;
|
||
|
|
||
|
struct obpile_s *pack;
|
||
|
|
||
|
struct flagpile_s *flags;
|
||
|
|
||
|
// for loading
|
||
|
long oblist[MAXPILEOBS];
|
||
|
int x,y;
|
||
|
|
||
|
|
||
|
struct cell_s *cell;
|
||
|
struct lifeform_s *next, *prev;
|
||
|
} lifeform_t;
|
||
|
|
||
|
|
||
|
typedef struct obpile_s {
|
||
|
lifeform_t *owner;// } Only one of these
|
||
|
cell_t *where; // } should be filled in
|
||
|
struct object_s *first,*last;
|
||
|
|
||
|
// for loading
|
||
|
long oblist[MAXPILEOBS];
|
||
|
} obpile_t;
|
||
|
|
||
|
|
||
|
typedef struct flagpile_s {
|
||
|
struct flag_s *first,*last;
|
||
|
} flagpile_t;
|
||
|
|
||
|
typedef struct flag_s {
|
||
|
enum FLAG id;
|
||
|
int nvals;
|
||
|
int val[3];
|
||
|
char *text;
|
||
|
struct flagpile_s *pile;
|
||
|
struct flag_s *next, *prev;
|
||
|
} flag_t;
|
||
|
|
||
|
typedef struct material_s {
|
||
|
int id;
|
||
|
char *name;
|
||
|
struct material_s *next,*prev;
|
||
|
} material_t;
|
||
|
|
||
|
typedef struct objectclass_s {
|
||
|
enum OBCLASS id;
|
||
|
char *name;
|
||
|
char glyph;
|
||
|
struct objectclass_s *next, *prev;
|
||
|
} objectclass_t;
|
||
|
|
||
|
typedef struct objecttype_s {
|
||
|
enum OBTYPE id;
|
||
|
char *name;
|
||
|
char *desc;
|
||
|
struct objectclass_s *obclass;
|
||
|
material_t *material;
|
||
|
float weight; // in kilograms
|
||
|
struct flagpile_s *flags;
|
||
|
struct objecttype_s *next, *prev;
|
||
|
} objecttype_t;
|
||
|
|
||
|
typedef struct object_s {
|
||
|
long id; // unique for every ob in the game!
|
||
|
struct objecttype_s *type;
|
||
|
struct obpile_s *pile; // reverse pointer back to pile
|
||
|
// these variables are initially
|
||
|
// inherited from objecttype:
|
||
|
material_t *material;
|
||
|
float weight; // in kilograms
|
||
|
// flags
|
||
|
// these variables are NOT inherited
|
||
|
char *inscription;
|
||
|
char letter;
|
||
|
enum BLESSTYPE blessed;
|
||
|
int blessknown;
|
||
|
int amt; // for stackable objects
|
||
|
flagpile_t *flags;
|
||
|
|
||
|
struct object_s *next, *prev;
|
||
|
} object_t;
|
||
|
|
||
|
|
||
|
#endif
|
||
|
|