Angband
z-rand.h
Go to the documentation of this file.
1 
22 #ifndef INCLUDED_Z_RAND_H
23 #define INCLUDED_Z_RAND_H
24 
25 #include "h-basic.h"
26 
32 #define MAX_RAND_DEPTH 128
33 
40 typedef struct random {
41  int base;
42  int dice;
43  int sides;
44  int m_bonus;
45 } random_value;
46 
50 #define RAND_DEG 32
51 
55 typedef enum {
61 } aspect;
62 
63 
69 #define randint0(M) ((s32b) Rand_div(M))
70 
71 
77 #define randint1(M) ((s32b) Rand_div(M) + 1)
78 
85 #define rand_spread(A, D) ((A) + (randint0(1 + (D) + (D))) - (D))
86 
90 #define one_in_(x) (!randint0(x))
91 
95 extern bool Rand_quick;
96 
100 extern u32b Rand_value;
101 
105 extern u32b state_i;
106 extern u32b STATE[RAND_DEG];
107 extern u32b z0;
108 extern u32b z1;
109 extern u32b z2;
110 
111 
115 void Rand_state_init(u32b seed);
116 
120 void Rand_init(void);
121 
127 u32b Rand_div(u32b m);
128 
133 s16b Rand_normal(int mean, int stand);
134 
141 
145 int damroll(int num, int sides);
146 
150 int damcalc(int num, int sides, aspect dam_aspect);
151 
158 int rand_range(int A, int B);
159 
164 s16b m_bonus(int max, int level);
165 
169 s16b m_bonus_calc(int max, int level, aspect bonus_aspect);
170 
174 int randcalc(random_value v, int level, aspect rand_aspect);
175 
179 bool randcalc_valid(random_value v, int test);
180 
185 
186 extern void rand_fix(u32b val);
187 
188 #endif /* INCLUDED_Z_RAND_H */