1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
3 | |
3 | |
|
|
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | |
7 | This program is free software; you can redistribute it and/or modify |
8 | This program is free software; you can redistribute it and/or modify |
8 | it under the terms of the GNU General Public License as published by |
9 | it under the terms of the GNU General Public License as published by |
… | |
… | |
199 | |
200 | |
200 | /* decay and destroy perishable items in a map */ |
201 | /* decay and destroy perishable items in a map */ |
201 | void |
202 | void |
202 | maptile::decay_objects () |
203 | maptile::decay_objects () |
203 | { |
204 | { |
204 | int x, y, destroy; |
205 | if (!spaces) |
205 | object *op, *otmp; |
206 | return; |
206 | |
207 | |
207 | for (x = 0; x < width; x++) |
208 | for (mapspace *ms = spaces + size (); ms-- > spaces; ) |
208 | for (y = 0; y < height; y++) |
209 | for (object *above, *op = ms->bot; op; op = above) |
209 | for (op = at (x, y).bot; op; op = otmp) |
|
|
210 | { |
210 | { |
|
|
211 | above = op->above; |
|
|
212 | |
211 | destroy = 0; |
213 | bool destroy = 0; |
212 | otmp = op->above; |
|
|
213 | |
214 | |
|
|
215 | // do not decay anything above unique floor tiles (yet :) |
214 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
216 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) && QUERY_FLAG (op, FLAG_UNIQUE)) |
215 | break; |
217 | break; |
216 | |
218 | |
217 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) |
219 | if (QUERY_FLAG (op, FLAG_IS_FLOOR) |
218 | || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) |
220 | || QUERY_FLAG (op, FLAG_OBJ_ORIGINAL) |
219 | || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) |
221 | || QUERY_FLAG (op, FLAG_OBJ_SAVE_ON_OVL) |
220 | || QUERY_FLAG (op, FLAG_UNIQUE) |
222 | || QUERY_FLAG (op, FLAG_UNIQUE) |
221 | || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) |
223 | || QUERY_FLAG (op, FLAG_OVERLAY_FLOOR) |
222 | || QUERY_FLAG (op, FLAG_UNPAID) |
224 | || QUERY_FLAG (op, FLAG_UNPAID) |
223 | || op->is_alive ()) |
225 | || op->is_alive ()) |
224 | continue; |
226 | ; // do not decay |
225 | |
|
|
226 | /* otherwise, we decay and destroy */ |
|
|
227 | if (op->is_weapon ()) |
227 | else if (op->is_weapon ()) |
228 | { |
228 | { |
229 | op->stats.dam--; |
229 | op->stats.dam--; |
230 | if (op->stats.dam < 0) |
230 | if (op->stats.dam < 0) |
231 | destroy = 1; |
231 | destroy = 1; |
232 | } |
232 | } |
233 | else if (op->is_armor ()) |
233 | else if (op->is_armor ()) |
234 | { |
234 | { |
235 | op->stats.ac--; |
235 | op->stats.ac--; |
236 | if (op->stats.ac < 0) |
236 | if (op->stats.ac < 0) |
237 | destroy = 1; |
237 | destroy = 1; |
238 | } |
238 | } |
239 | else if (op->type == FOOD) |
239 | else if (op->type == FOOD) |
240 | { |
240 | { |
241 | op->stats.food -= rndm (5, 20); |
241 | op->stats.food -= rndm (5, 20); |
242 | if (op->stats.food < 0) |
242 | if (op->stats.food < 0) |
243 | destroy = 1; |
243 | destroy = 1; |
244 | } |
244 | } |
245 | else |
245 | else |
246 | { |
246 | { |
247 | if (op->material & M_PAPER || op->material & M_LEATHER || |
247 | int mat = op->material; |
248 | op->material & M_WOOD || op->material & M_ORGANIC || op->material & M_CLOTH || op->material & M_LIQUID) |
248 | |
|
|
249 | if (mat & M_PAPER |
|
|
250 | || mat & M_LEATHER |
|
|
251 | || mat & M_WOOD |
|
|
252 | || mat & M_ORGANIC |
|
|
253 | || mat & M_CLOTH |
|
|
254 | || mat & M_LIQUID |
|
|
255 | || (mat & M_IRON && rndm (1, 5) == 1) |
|
|
256 | || (mat & M_GLASS && rndm (1, 2) == 1) |
|
|
257 | || ((mat & M_STONE || mat & M_ADAMANT) && rndm (1, 10) == 1) |
|
|
258 | || ((mat & M_SOFT_METAL || mat & M_BONE) && rndm (1, 3) == 1) |
|
|
259 | || (mat & M_ICE && temp > 32)) |
249 | destroy = 1; |
260 | destroy = 1; |
250 | |
|
|
251 | if (op->material & M_IRON && rndm (1, 5) == 1) |
|
|
252 | destroy = 1; |
|
|
253 | |
|
|
254 | if (op->material & M_GLASS && rndm (1, 2) == 1) |
|
|
255 | destroy = 1; |
|
|
256 | |
|
|
257 | if ((op->material & M_STONE || op->material & 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) |
|
|
261 | destroy = 1; |
|
|
262 | |
|
|
263 | if (op->material & M_ICE && temp > 32) |
|
|
264 | destroy = 1; |
|
|
265 | } |
261 | } |
266 | |
262 | |
267 | /* adjust overall chance below */ |
263 | /* adjust overall chance below */ |
268 | if (destroy && rndm (0, 1)) |
264 | if (destroy && rndm (0, 1)) |
269 | op->destroy (); |
265 | op->destroy (); |
270 | } |
266 | } |
271 | } |
267 | } |
272 | |
268 | |
273 | /* convert materialname to materialtype_t */ |
269 | /* convert materialname to materialtype_t */ |
274 | |
270 | |
275 | materialtype_t * |
271 | materialtype_t * |