1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | * |
7 | * |
… | |
… | |
230 | * start with equipment, but only their abilities). |
230 | * start with equipment, but only their abilities). |
231 | */ |
231 | */ |
232 | static void |
232 | static void |
233 | put_treasure (object *op, object *creator, int flags) |
233 | put_treasure (object *op, object *creator, int flags) |
234 | { |
234 | { |
235 | object *tmp; |
235 | if (flags & GT_ENVIRONMENT) |
236 | |
236 | { |
237 | /* Bit of a hack - spells should never be put onto the map. The entire |
237 | /* Bit of a hack - spells should never be put onto the map. The entire |
238 | * treasure stuff is a problem - there is no clear idea of knowing |
238 | * treasure stuff is a problem - there is no clear idea of knowing |
239 | * this is the original object, or if this is an object that should be created |
239 | * this is the original object, or if this is an object that should be created |
240 | * by another object. |
240 | * by another object. |
241 | */ |
241 | */ |
242 | if (flags & GT_ENVIRONMENT && op->type != SPELL) |
242 | //TODO: flag such as objects... as such (no drop, anybody?) |
243 | { |
243 | if (op->type == SPELL) |
|
|
244 | { |
|
|
245 | op->destroy (); |
|
|
246 | return; |
|
|
247 | } |
|
|
248 | |
|
|
249 | op->expand_tail (); |
|
|
250 | |
|
|
251 | if (ob_blocked (op, creator->map, creator->x, creator->y)) |
|
|
252 | op->destroy (); |
|
|
253 | else |
|
|
254 | { |
244 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
255 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
245 | op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); |
256 | op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); |
|
|
257 | } |
246 | } |
258 | } |
247 | else |
259 | else |
248 | { |
260 | { |
249 | op = creator->insert (op); |
261 | op = creator->insert (op); |
250 | |
262 | |
251 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
263 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
252 | monster_check_apply (creator, op); |
264 | monster_check_apply (creator, op); |
253 | |
265 | |
254 | if ((flags & GT_UPDATE_INV) && (tmp = creator->in_player ())) |
266 | if (flags & GT_UPDATE_INV) |
|
|
267 | if (object *tmp = creator->in_player ()) |
255 | esrv_send_item (tmp, op); |
268 | esrv_send_item (tmp, op); |
256 | } |
269 | } |
257 | } |
270 | } |
258 | |
271 | |
259 | /* if there are change_xxx commands in the treasure, we include the changes |
272 | /* if there are change_xxx commands in the treasure, we include the changes |
260 | * in the generated object |
273 | * in the generated object |
… | |
… | |
358 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
371 | fix_generated_item (tmp, op, difficulty, t->magic, flag); |
359 | change_treasure (t, tmp); |
372 | change_treasure (t, tmp); |
360 | put_treasure (tmp, op, flag); |
373 | put_treasure (tmp, op, flag); |
361 | } |
374 | } |
362 | } |
375 | } |
|
|
376 | } |
|
|
377 | |
|
|
378 | void |
|
|
379 | object::create_treasure (treasurelist *tl, int flags) |
|
|
380 | { |
|
|
381 | ::create_treasure (tl, this, flags, map ? map->difficulty : 0); |
363 | } |
382 | } |
364 | |
383 | |
365 | /* This calls the appropriate treasure creation function. tries is passed |
384 | /* This calls the appropriate treasure creation function. tries is passed |
366 | * to determine how many list transitions or attempts to create treasure |
385 | * to determine how many list transitions or attempts to create treasure |
367 | * have been made. It is really in place to prevent infinite loops with |
386 | * have been made. It is really in place to prevent infinite loops with |
… | |
… | |
1566 | if (change->msg) |
1585 | if (change->msg) |
1567 | op->msg = change->msg; |
1586 | op->msg = change->msg; |
1568 | } |
1587 | } |
1569 | |
1588 | |
1570 | static int |
1589 | static int |
1571 | legal_artifact_combination (object *op, artifact * art) |
1590 | legal_artifact_combination (object *op, artifact *art) |
1572 | { |
1591 | { |
1573 | int neg, success = 0; |
1592 | int neg, success = 0; |
1574 | linked_char *tmp; |
1593 | linked_char *tmp; |
1575 | const char *name; |
1594 | const char *name; |
1576 | |
1595 | |
1577 | if (art->allowed == (linked_char *) NULL) |
1596 | if (!art->allowed) |
1578 | return 1; /* Ie, "all" */ |
1597 | return 1; /* Ie, "all" */ |
|
|
1598 | |
1579 | for (tmp = art->allowed; tmp; tmp = tmp->next) |
1599 | for (tmp = art->allowed; tmp; tmp = tmp->next) |
1580 | { |
1600 | { |
1581 | #ifdef TREASURE_VERBOSE |
1601 | #ifdef TREASURE_VERBOSE |
1582 | LOG (llevDebug, "legal_art: %s\n", &tmp->name); |
1602 | LOG (llevDebug, "legal_art: %s\n", &tmp->name); |
1583 | #endif |
1603 | #endif |
… | |
… | |
1594 | * everything is allowed except what we match |
1614 | * everything is allowed except what we match |
1595 | */ |
1615 | */ |
1596 | else if (neg) |
1616 | else if (neg) |
1597 | success = 1; |
1617 | success = 1; |
1598 | } |
1618 | } |
|
|
1619 | |
1599 | return success; |
1620 | return success; |
1600 | } |
1621 | } |
1601 | |
1622 | |
1602 | /* |
1623 | /* |
1603 | * Fixes the given object, giving it the abilities and titles |
1624 | * Fixes the given object, giving it the abilities and titles |