… | |
… | |
199 | |
199 | |
200 | /* decay and destroy perishable items in a map */ |
200 | /* decay and destroy perishable items in a map */ |
201 | void |
201 | void |
202 | maptile::decay_objects () |
202 | maptile::decay_objects () |
203 | { |
203 | { |
204 | int x, y, destroy; |
|
|
205 | object *op, *otmp; |
|
|
206 | |
|
|
207 | for (x = 0; x < width; x++) |
204 | for (int x = 0; x < width; x++) |
208 | for (y = 0; y < height; y++) |
205 | for (int y = 0; y < height; y++) |
209 | for (op = at (x, y).bot; op; op = otmp) |
206 | for (object *above = 0, *op = at (x, y).bot; op; op = above) |
210 | { |
207 | { |
211 | destroy = 0; |
208 | bool destroy = 0; |
|
|
209 | |
212 | otmp = op->above; |
210 | above = op->above; |
213 | |
211 | |
|
|
212 | // do not decay anything above unique floor tiles (yet :) |
214 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
213 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
215 | break; |
214 | break; |
216 | |
215 | |
217 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) |
216 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) |
218 | || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) |
217 | || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) |
219 | || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) |
218 | || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) |
220 | || QUERY_FLAG (op, FLAG_UNIQUE) |
219 | || QUERY_FLAG (op, FLAG_UNIQUE) |
221 | || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) |
220 | || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) |
222 | || QUERY_FLAG (op, FLAG_UNPAID) |
221 | || QUERY_FLAG (op, FLAG_UNPAID) |
223 | || op->is_alive ()) |
222 | || op->is_alive ()) |
224 | continue; |
223 | ; // do not decay |
225 | |
|
|
226 | /* otherwise, we decay and destroy */ |
|
|
227 | if (op->is_weapon ()) |
224 | else if (op->is_weapon ()) |
228 | { |
225 | { |
229 | op->stats.dam--; |
226 | op->stats.dam--; |
230 | if (op->stats.dam < 0) |
227 | if (op->stats.dam < 0) |
231 | destroy = 1; |
228 | destroy = 1; |
232 | } |
229 | } |
… | |
… | |
242 | if (op->stats.food < 0) |
239 | if (op->stats.food < 0) |
243 | destroy = 1; |
240 | destroy = 1; |
244 | } |
241 | } |
245 | else |
242 | else |
246 | { |
243 | { |
247 | if (op->material & M_PAPER || op->material & M_LEATHER || |
244 | int mat = op->material; |
248 | op->material & M_WOOD || op->material & M_ORGANIC || op->material & M_CLOTH || op->material & M_LIQUID) |
|
|
249 | destroy = 1; |
|
|
250 | |
245 | |
|
|
246 | if (mat & M_PAPER |
|
|
247 | || mat & M_LEATHER |
|
|
248 | || mat & M_WOOD |
|
|
249 | || mat & M_ORGANIC |
|
|
250 | || mat & M_CLOTH |
|
|
251 | || mat & M_LIQUID |
251 | if (op->material & M_IRON && rndm (1, 5) == 1) |
252 | || (mat & M_IRON && rndm (1, 5) == 1) |
252 | destroy = 1; |
|
|
253 | |
|
|
254 | if (op->material & M_GLASS && rndm (1, 2) == 1) |
253 | || (mat & M_GLASS && rndm (1, 2) == 1) |
255 | destroy = 1; |
|
|
256 | |
|
|
257 | if ((op->material & M_STONE || op->material & M_ADAMANT) && rndm (1, 10) == 1) |
254 | || ((mat & M_STONE || mat & M_ADAMANT) && rndm (1, 10) == 1) |
258 | destroy = 1; |
|
|
259 | |
|
|
260 | if ((op->material & M_SOFT_METAL || op->material & M_BONE) && rndm (1, 3) == 1) |
255 | || ((mat & M_SOFT_METAL || mat & M_BONE) && rndm (1, 3) == 1) |
261 | destroy = 1; |
|
|
262 | |
|
|
263 | if (op->material & M_ICE && temp > 32) |
256 | || (mat & M_ICE && temp > 32)) |
264 | destroy = 1; |
257 | destroy = 1; |
265 | } |
258 | } |
266 | |
259 | |
267 | /* adjust overall chance below */ |
260 | /* adjust overall chance below */ |
268 | if (destroy && rndm (0, 1)) |
261 | if (destroy && rndm (0, 1)) |