… | |
… | |
22 | |
22 | |
23 | #include <global.h> |
23 | #include <global.h> |
24 | |
24 | |
25 | #include "noise.h" |
25 | #include "noise.h" |
26 | |
26 | |
|
|
27 | ///////////////////////////////////////////////////////////////////////////// |
|
|
28 | |
|
|
29 | static bool |
|
|
30 | has_floor (maptile *m, sint16 x, sint16 y) |
|
|
31 | { |
|
|
32 | mapxy pos (m, x, y); |
|
|
33 | |
|
|
34 | if (!pos.normalise ()) |
|
|
35 | return true; |
|
|
36 | |
|
|
37 | mapspace &ms = pos.ms (); |
|
|
38 | |
|
|
39 | for (object *ob = ms.bot; ob; ob = ob->above) |
|
|
40 | if (ob->arch->archname == shstr_quad_open_space) |
|
|
41 | return false; |
|
|
42 | else if (ob->flag [FLAG_IS_FLOOR]) |
|
|
43 | return true; |
|
|
44 | |
|
|
45 | return false; |
|
|
46 | } |
|
|
47 | |
|
|
48 | void |
|
|
49 | move_into_wall (object *ob, object *wall) |
|
|
50 | { |
|
|
51 | bool visible = !wall->invisible && !ob->flag [FLAG_BLIND]; |
|
|
52 | |
|
|
53 | if (wall->flag [FLAG_IS_QUAD] && visible) |
|
|
54 | { |
|
|
55 | maptile *m = wall->map; |
|
|
56 | |
|
|
57 | if (m->tile_path [TILE_UP]) |
|
|
58 | if (maptile *up = m->tile_available (TILE_UP)) |
|
|
59 | { |
|
|
60 | if (ob->blocked (up, ob->x, ob->y) || has_floor (up, ob->x, ob->y)) |
|
|
61 | ob->failmsg (format ("Ouch, you hit your head while climbing the %s! H<Didn't you see the ceiling? :)>", query_name (wall))); |
|
|
62 | //TODO: reduce health |
|
|
63 | else if (ob->blocked (up, wall->x, wall->y)) |
|
|
64 | ob->failmsg (format ("You try to climb up, but the %s is too high for you! H<No free space on top of this block.>", query_name (wall))); |
|
|
65 | //TODO: reduce health |
|
|
66 | else |
|
|
67 | { |
|
|
68 | ob->statusmsg (format ("You successfully climb up the %s.", query_name (wall))); |
|
|
69 | // here we assume that ob is a player... |
|
|
70 | ob->enter_map (up, wall->x, wall->y); |
|
|
71 | } |
|
|
72 | } |
|
|
73 | else |
|
|
74 | ob->failmsg (format ("You try to climb the %s, but you fall down! H<Try again.>", query_name (wall))); |
|
|
75 | else |
|
|
76 | ob->failmsg (format ("You fail to climb up the %s! H<You cannot climb up here.>", query_name (wall))); |
|
|
77 | |
|
|
78 | |
|
|
79 | return; |
|
|
80 | } |
|
|
81 | |
|
|
82 | if (ob->contr->ns->bumpmsg) |
|
|
83 | { |
|
|
84 | ob->play_sound (sound_find ("bump_wall")); |
|
|
85 | |
|
|
86 | ob->statusmsg (visible |
|
|
87 | ? format ("You bump into the %s.", query_name (wall)) |
|
|
88 | : "You bump into something." |
|
|
89 | ); |
|
|
90 | } |
|
|
91 | } |
|
|
92 | |
|
|
93 | ///////////////////////////////////////////////////////////////////////////// |
|
|
94 | |
|
|
95 | // this mapspace has changed - potentialyl activate dormant physics objects |
|
|
96 | // in the vicinity |
|
|
97 | |
|
|
98 | void update_physics (maptile *m, int x, int y) |
|
|
99 | { |
|
|
100 | } |
|
|
101 | |
|
|
102 | // handle physics updates |
|
|
103 | void move_physics (object *ob) |
|
|
104 | { |
|
|
105 | } |
|
|
106 | |
|
|
107 | ///////////////////////////////////////////////////////////////////////////// |
|
|
108 | |
27 | #define FANCY_GRAPHICS 0 |
109 | #define FANCY_GRAPHICS 0 |
28 | |
110 | |
29 | static void |
111 | static void |
30 | gen_quadspace (maptile *m, int mx, int my, int x, int y, int z) |
112 | gen_quadspace (maptile *m, int mx, int my, int x, int y, int z) |
31 | { |
113 | { |
… | |
… | |
72 | T_OCEAN, |
154 | T_OCEAN, |
73 | T_RIVER, |
155 | T_RIVER, |
74 | T_VALLEY, |
156 | T_VALLEY, |
75 | T_MOUNTAIN, |
157 | T_MOUNTAIN, |
76 | T_UNDERGROUND, |
158 | T_UNDERGROUND, |
|
|
159 | T_AIR, // unused |
77 | T_ACQUIFER, |
160 | T_ACQUIFER, |
78 | } t = T_NONE; |
161 | } t = T_NONE; |
79 | |
162 | |
80 | vec3d c; |
163 | vec3d c; |
81 | int h0 = 0; // "water level" |
164 | int h0 = 0; // "water level" |
… | |
… | |
135 | |
218 | |
136 | max_it (h0, h); |
219 | max_it (h0, h); |
137 | |
220 | |
138 | // everything below the surface is underground, or a variant |
221 | // everything below the surface is underground, or a variant |
139 | if (z < h) |
222 | if (z < h) |
140 | { |
|
|
141 | t = T_UNDERGROUND; |
223 | t = T_UNDERGROUND; |
142 | } |
|
|
143 | |
224 | |
144 | // put acquifers a bit below the surface, to reduce them leaking out (will still happen) |
225 | // put acquifers a bit below the surface, to reduce them leaking out (will still happen) |
145 | if (z < h - 3) |
226 | if (z < h - 3) |
146 | { |
227 | { |
147 | static frac3d acquifer_gen (4); |
228 | static frac3d acquifer_gen (4); |
… | |
… | |
168 | putc (clamp<int> (255 * c[2], 0, 255), stdout); |
249 | putc (clamp<int> (255 * c[2], 0, 255), stdout); |
169 | #else |
250 | #else |
170 | shstr arch_floor = shstr ("quad_open_space"); |
251 | shstr arch_floor = shstr ("quad_open_space"); |
171 | shstr arch_wall; |
252 | shstr arch_wall; |
172 | |
253 | |
|
|
254 | // TODO: this is shit - we should never generatea water surface, but only |
|
|
255 | // water above the surface |
173 | switch (t) |
256 | switch (t) |
174 | { |
257 | { |
175 | case T_OCEAN: |
258 | case T_OCEAN: |
|
|
259 | if (z < h0) |
|
|
260 | arch_wall = shstr ("quad_water_wall"); |
|
|
261 | else if (z == h0) |
|
|
262 | arch_floor = shstr ("quad_ocean_floor"); |
|
|
263 | break; |
|
|
264 | |
176 | case T_RIVER: |
265 | case T_RIVER: |
177 | if (z < h0) |
266 | if (z < h0) |
178 | arch_wall = shstr ("quad_water_wall"); |
267 | arch_wall = shstr ("quad_water_wall"); |
|
|
268 | else if (z == h0) |
|
|
269 | arch_floor = shstr ("quad_water_floor"); |
179 | break; |
270 | break; |
180 | |
271 | |
181 | case T_VALLEY: |
272 | case T_VALLEY: |
182 | if (z == h) |
273 | if (z == h) |
183 | arch_floor = shstr ("quad_dirt_floor"); |
274 | arch_floor = shstr ("quad_dirt_floor"); |
… | |
… | |
227 | for (int mx = 0; mx < 50; ++mx) |
318 | for (int mx = 0; mx < 50; ++mx) |
228 | for (int my = 0; my < 50; ++my) |
319 | for (int my = 0; my < 50; ++my) |
229 | gen_quadspace (m, mx, my, x + mx, y + my, z); |
320 | gen_quadspace (m, mx, my, x + mx, y + my, z); |
230 | } |
321 | } |
231 | |
322 | |
|
|
323 | ///////////////////////////////////////////////////////////////////////////// |
|
|
324 | |
232 | void noise_test (); |
325 | void noise_test (); |
233 | void noise_test () |
326 | void noise_test () |
234 | { |
327 | { |
235 | #if 1 |
328 | #if 1 |
236 | int Nw = 700; |
329 | int Nw = 700; |