summaryrefslogtreecommitdiffstats
path: root/trunk/source/stuff.h
blob: 72c7d2dcf5ff5a29cc3b129b27e45ee0daad9820 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/*
 *  File:       stuff.cc
 *  Summary:    Misc stuff.
 *  Written by: Linley Henzell
 *
 *  Change History (most recent first):
 *
 *   <3>    11/14/99     cdl    added random40
 *   <2>    11/06/99     cdl    added random22
 *   <1>     -/--/--     LRH    Created
 */


#ifndef STUFF_H
#define STUFF_H

#include "externs.h"

char *const make_time_string(time_t abs_time, char *const buff, int buff_size, bool terse = false);

void set_redraw_status( unsigned long flags );

void tag_followers( void );
void untag_followers( void );

void seed_rng(void);

void seed_rng(long seed);

void push_rng_state();

void pop_rng_state();

// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: acr
 * *********************************************************************** */
void cf_setseed(void);


/* ***********************************************************************
 * called from: xxx
 * *********************************************************************** */
bool coinflip(void);


/* ***********************************************************************
 * called from: xxx
 * *********************************************************************** */
bool one_chance_in(int a_million);


/* ***********************************************************************
 * called from: xxx
 * *********************************************************************** */
int random2(int randmax);

unsigned long random_int(void);

/* ***********************************************************************
 * called from: xxx
 * *********************************************************************** */
int random2avg( int max, int rolls );

int roll_dice( int num, int size );
int roll_dice( const struct dice_def &dice );


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: beam - fight - misc
 * *********************************************************************** */
int random2limit(int max, int limit);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: bang - beam - monplace - monstuff - spells1 - spells2 -
 *              spells4 - view
 * *********************************************************************** */
bool see_grid(unsigned char grx, unsigned char gry);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: spells2
 * *********************************************************************** */
int stepdown_value(int base_value, int stepping, int first_step, int last_step, int ceiling_value);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: ability - command - effects - food - item_use - items -
 *              newgame - ouch - shopping - spell - spl-book - spells1 -
 *              spells3
 * *********************************************************************** */
unsigned char get_ch(void);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: files - newgame - ouch
 * *********************************************************************** */
void end(int end_arg);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: newgame
 * *********************************************************************** */
void modify_all_stats(int STmod, int IQmod, int DXmod);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: ability - acr - command - direct - invent - item_use -
 *              religion - shopping - spell - spl-book - spells3
 * *********************************************************************** */
void redraw_screen(void);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: ability - acr - beam - command - decks - debug - effects -
 *              it_use3 - item_use - items - misc - ouch - religion -
 *              spell - spl-book - spells - spells1 - spells2 - spells3 -
 *              spells4
 * *********************************************************************** */
void canned_msg(unsigned char which_message);


// last updated 12may2000 {dlb}
/* ***********************************************************************
 * called from: ability - acr - command - it_use3 - item_use - items -
 *              misc - ouch - religion - spl-book - spells4
 * *********************************************************************** */
// If safeanswer is nonzero, it should be a lowercase letter.
bool yesno( const char * str, bool safe = true, int safeanswer = 0, 
            bool clear_after = true );


// last updated 21may2000 {dlb}
/* ***********************************************************************
 * called from: fight - monstuff - spells4 - view
 * *********************************************************************** */
int grid_distance( int x, int y, int x2, int y2 );
int distance( int x, int y, int x2, int y2);
bool adjacent( int x, int y, int x2, int y2 );


// last updated 21may2000 {dlb}
/* ***********************************************************************
 * called from: ability - acr - bang - beam - effects - fight - it_use2 -
 *              it_use3 - monstuff - mstuff2 - religion - spell - spells -
 *              spells3 - spells4 - stuff - view
 * *********************************************************************** */
bool silenced(char x, char y);


// last updated XXmay2000 {dlb}
/* ***********************************************************************
 * called from: xxx
 * *********************************************************************** */
bool player_can_hear(char x, char y);


// last updated 27may2000 {dlb}
/* ***********************************************************************
 * called from: dungeon - files - it_use2 - it_use3 - monstuff - mon-util -
 *              mstuff2 - newgame - spells - view
 * *********************************************************************** */
unsigned char random_colour(void);


// last updated 08jun2000 {dlb}
/* ***********************************************************************
 * called from: ability - chardump - command - files - invent - item_use -
 *              items - newgame - spl-book - spells0 - spells1
 * *********************************************************************** */
char index_to_letter (int the_index);


// last updated 08jun2000 {dlb}
/* ***********************************************************************
 * called from: ability - command - food - it_use3 - item_use - items -
 *              spell - spl-book - spells1 - spells3
 * *********************************************************************** */
int letter_to_index(int the_letter);


// last updated 16mar2001 {dlb}
/* ***********************************************************************
 * called from: monplace
 * *********************************************************************** */
int near_stairs(int px, int py, int max_dist, unsigned char &stair_gfx);

// last updated 16mar2001 {dlb}
/* ***********************************************************************
 * called from: fight
 * *********************************************************************** */
// just want to do this in a consistent fashion
inline bool testbits(unsigned int flags, unsigned int test)
{
    return ((flags & test) == test);
}

#endif