… | |
… | |
255 | return; |
255 | return; |
256 | } |
256 | } |
257 | |
257 | |
258 | op->expand_tail (); |
258 | op->expand_tail (); |
259 | |
259 | |
|
|
260 | if (!creator->is_on_map () |
260 | if (!creator->is_on_map () || op->blocked (creator->map, creator->x, creator->y)) |
261 | || (op->weight && op->blocked (creator->map, creator->x, creator->y))) |
261 | op->destroy (); |
262 | op->destroy (); |
262 | else |
263 | else |
263 | { |
264 | { |
264 | SET_FLAG (op, FLAG_OBJ_ORIGINAL); |
265 | op->flag [FLAG_OBJ_ORIGINAL] = true; |
265 | op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); |
266 | op->insert_at (creator, creator, INS_NO_MERGE | INS_NO_WALK_ON); |
266 | } |
267 | } |
267 | } |
268 | } |
268 | else |
269 | else |
269 | { |
270 | { |
270 | op = creator->insert (op); |
271 | op = creator->insert (op); |
271 | |
272 | |
272 | if ((flags & GT_APPLY) && QUERY_FLAG (creator, FLAG_MONSTER)) |
273 | if ((flags & GT_APPLY) && creator->flag [FLAG_MONSTER]) |
273 | monster_check_apply (creator, op); |
274 | monster_check_apply (creator, op); |
274 | } |
275 | } |
275 | } |
276 | } |
276 | |
277 | |
277 | /* if there are change_xxx commands in the treasure, we include the changes |
278 | /* if there are change_xxx commands in the treasure, we include the changes |
… | |
… | |
611 | i = -i; |
612 | i = -i; |
612 | if (i > max_magic) |
613 | if (i > max_magic) |
613 | i = max_magic; |
614 | i = max_magic; |
614 | set_abs_magic (op, i); |
615 | set_abs_magic (op, i); |
615 | if (i < 0) |
616 | if (i < 0) |
616 | SET_FLAG (op, FLAG_CURSED); |
617 | op->set_flag (FLAG_CURSED); |
617 | } |
618 | } |
618 | |
619 | |
619 | /* |
620 | /* |
620 | * Randomly adds one magical ability to the given object. |
621 | * Randomly adds one magical ability to the given object. |
621 | * Modified for Partial Resistance in many ways: |
622 | * Modified for Partial Resistance in many ways: |
… | |
… | |
714 | break; |
715 | break; |
715 | } |
716 | } |
716 | case 20: |
717 | case 20: |
717 | if (op->type == AMULET) |
718 | if (op->type == AMULET) |
718 | { |
719 | { |
719 | SET_FLAG (op, FLAG_REFL_SPELL); |
720 | op->set_flag (FLAG_REFL_SPELL); |
720 | op->value *= 11; |
721 | op->value *= 11; |
721 | } |
722 | } |
722 | else |
723 | else |
723 | { |
724 | { |
724 | op->stats.hp = 1; /* regenerate hit points */ |
725 | op->stats.hp = 1; /* regenerate hit points */ |
… | |
… | |
727 | break; |
728 | break; |
728 | |
729 | |
729 | case 21: |
730 | case 21: |
730 | if (op->type == AMULET) |
731 | if (op->type == AMULET) |
731 | { |
732 | { |
732 | SET_FLAG (op, FLAG_REFL_MISSILE); |
733 | op->set_flag (FLAG_REFL_MISSILE); |
733 | op->value *= 9; |
734 | op->value *= 9; |
734 | } |
735 | } |
735 | else |
736 | else |
736 | { |
737 | { |
737 | op->stats.sp = 1; /* regenerate spell points */ |
738 | op->stats.sp = 1; /* regenerate spell points */ |
… | |
… | |
923 | case WEAPON: |
924 | case WEAPON: |
924 | case ARMOUR: |
925 | case ARMOUR: |
925 | case SHIELD: |
926 | case SHIELD: |
926 | case HELMET: |
927 | case HELMET: |
927 | case CLOAK: |
928 | case CLOAK: |
928 | if (QUERY_FLAG (op, FLAG_CURSED) && !(rndm (4))) |
929 | if (op->flag [FLAG_CURSED] && !(rndm (4))) |
929 | set_ring_bonus (op, -DICE2); |
930 | set_ring_bonus (op, -DICE2); |
930 | break; |
931 | break; |
931 | |
932 | |
932 | case BRACERS: |
933 | case BRACERS: |
933 | if (!rndm (QUERY_FLAG (op, FLAG_CURSED) ? 5 : 20)) |
934 | if (!rndm (op->flag [FLAG_CURSED] ? 5 : 20)) |
934 | { |
935 | { |
935 | set_ring_bonus (op, QUERY_FLAG (op, FLAG_CURSED) ? -DICE2 : DICE2); |
936 | set_ring_bonus (op, op->flag [FLAG_CURSED] ? -DICE2 : DICE2); |
936 | if (!QUERY_FLAG (op, FLAG_CURSED)) |
937 | if (!op->flag [FLAG_CURSED]) |
937 | op->value *= 3; |
938 | op->value *= 3; |
938 | } |
939 | } |
939 | break; |
940 | break; |
940 | |
941 | |
941 | case POTION: |
942 | case POTION: |
… | |
… | |
971 | op->name = "potion"; |
972 | op->name = "potion"; |
972 | op->name_pl = "potions"; |
973 | op->name_pl = "potions"; |
973 | } |
974 | } |
974 | |
975 | |
975 | if (!(flags & GT_ONLY_GOOD) && rndm (2)) |
976 | if (!(flags & GT_ONLY_GOOD) && rndm (2)) |
976 | SET_FLAG (op, FLAG_CURSED); |
977 | op->set_flag (FLAG_CURSED); |
977 | |
978 | |
978 | break; |
979 | break; |
979 | } |
980 | } |
980 | |
981 | |
981 | case AMULET: |
982 | case AMULET: |
… | |
… | |
985 | case RING: |
986 | case RING: |
986 | if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */ |
987 | if (!IS_ARCH (op->arch, ring) && !IS_ARCH (op->arch, amulet)) /* It's a special artifact! */ |
987 | break; |
988 | break; |
988 | |
989 | |
989 | if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) |
990 | if (!(flags & GT_ONLY_GOOD) && !(rndm (3))) |
990 | SET_FLAG (op, FLAG_CURSED); |
991 | op->set_flag (FLAG_CURSED); |
991 | |
992 | |
992 | set_ring_bonus (op, QUERY_FLAG (op, FLAG_CURSED) ? -DICE2 : DICE2); |
993 | set_ring_bonus (op, op->flag [FLAG_CURSED] ? -DICE2 : DICE2); |
993 | |
994 | |
994 | if (op->type != RING) /* Amulets have only one ability */ |
995 | if (op->type != RING) /* Amulets have only one ability */ |
995 | break; |
996 | break; |
996 | |
997 | |
997 | if (!(rndm (4))) |
998 | if (!(rndm (4))) |
998 | { |
999 | { |
999 | int d = (rndm (2) || QUERY_FLAG (op, FLAG_CURSED)) ? -DICE2 : DICE2; |
1000 | int d = (rndm (2) || op->flag [FLAG_CURSED]) ? -DICE2 : DICE2; |
1000 | |
1001 | |
1001 | if (d > 0) |
1002 | if (d > 0) |
1002 | op->value *= 3; |
1003 | op->value *= 3; |
1003 | |
1004 | |
1004 | set_ring_bonus (op, d); |
1005 | set_ring_bonus (op, d); |
1005 | |
1006 | |
1006 | if (!(rndm (4))) |
1007 | if (!(rndm (4))) |
1007 | { |
1008 | { |
1008 | int d = (rndm (3) || QUERY_FLAG (op, FLAG_CURSED)) ? -DICE2 : DICE2; |
1009 | int d = (rndm (3) || op->flag [FLAG_CURSED]) ? -DICE2 : DICE2; |
1009 | |
1010 | |
1010 | if (d > 0) |
1011 | if (d > 0) |
1011 | op->value *= 5; |
1012 | op->value *= 5; |
1012 | set_ring_bonus (op, d); |
1013 | set_ring_bonus (op, d); |
1013 | } |
1014 | } |
… | |
… | |
1024 | * creator and/or map level we found it on. |
1025 | * creator and/or map level we found it on. |
1025 | */ |
1026 | */ |
1026 | if (!op->msg && rndm (10)) |
1027 | if (!op->msg && rndm (10)) |
1027 | { |
1028 | { |
1028 | /* set the book level properly */ |
1029 | /* set the book level properly */ |
1029 | if (creator->level == 0 || QUERY_FLAG (creator, FLAG_ALIVE)) |
1030 | if (creator->level == 0 || creator->flag [FLAG_ALIVE]) |
1030 | { |
1031 | { |
1031 | if (op->map && op->map->difficulty) |
1032 | if (op->map && op->map->difficulty) |
1032 | op->level = rndm (op->map->difficulty) + rndm (10) + 1; |
1033 | op->level = rndm (op->map->difficulty) + rndm (10) + 1; |
1033 | else |
1034 | else |
1034 | op->level = rndm (20) + 1; |
1035 | op->level = rndm (20) + 1; |
… | |
… | |
1047 | /* creator related stuff */ |
1048 | /* creator related stuff */ |
1048 | |
1049 | |
1049 | /* for library, chained books. Note that some monsters have no_pick |
1050 | /* for library, chained books. Note that some monsters have no_pick |
1050 | * set - we don't want to set no pick in that case. |
1051 | * set - we don't want to set no pick in that case. |
1051 | */ |
1052 | */ |
1052 | if (QUERY_FLAG (creator, FLAG_NO_PICK) && !QUERY_FLAG (creator, FLAG_MONSTER)) |
1053 | if (creator->flag [FLAG_NO_PICK] && !creator->flag [FLAG_MONSTER]) |
1053 | SET_FLAG (op, FLAG_NO_PICK); |
1054 | op->set_flag (FLAG_NO_PICK); |
1054 | if (creator->slaying && !op->slaying) /* for check_inv floors */ |
1055 | if (creator->slaying && !op->slaying) /* for check_inv floors */ |
1055 | op->slaying = creator->slaying; |
1056 | op->slaying = creator->slaying; |
1056 | break; |
1057 | break; |
1057 | |
1058 | |
1058 | case SPELLBOOK: |
1059 | case SPELLBOOK: |
… | |
… | |
1121 | break; |
1122 | break; |
1122 | } /* switch type */ |
1123 | } /* switch type */ |
1123 | |
1124 | |
1124 | if (flags & GT_STARTEQUIP) |
1125 | if (flags & GT_STARTEQUIP) |
1125 | { |
1126 | { |
1126 | if (op->nrof < 2 && op->type != CONTAINER && op->type != MONEY && !QUERY_FLAG (op, FLAG_IS_THROWN)) |
1127 | if (op->nrof < 2 && op->type != CONTAINER && op->type != MONEY && !op->flag [FLAG_IS_THROWN]) |
1127 | SET_FLAG (op, FLAG_STARTEQUIP); |
1128 | op->set_flag (FLAG_STARTEQUIP); |
1128 | else if (op->type != MONEY) |
1129 | else if (op->type != MONEY) |
1129 | op->value = 0; |
1130 | op->value = 0; |
1130 | } |
1131 | } |
1131 | |
1132 | |
1132 | if (!(flags & GT_ENVIRONMENT)) |
1133 | if (!(flags & GT_ENVIRONMENT)) |
… | |
… | |
1314 | op->path_repelled |= change->path_repelled; |
1315 | op->path_repelled |= change->path_repelled; |
1315 | op->path_denied |= change->path_denied; |
1316 | op->path_denied |= change->path_denied; |
1316 | op->move_type |= change->move_type; |
1317 | op->move_type |= change->move_type; |
1317 | op->stats.luck += change->stats.luck; |
1318 | op->stats.luck += change->stats.luck; |
1318 | |
1319 | |
1319 | if (QUERY_FLAG (change, FLAG_CURSED)) |
1320 | if (change->flag [FLAG_CURSED]) |
1320 | SET_FLAG (op, FLAG_CURSED); |
1321 | op->set_flag (FLAG_CURSED); |
1321 | if (QUERY_FLAG (change, FLAG_DAMNED)) |
1322 | if (change->flag [FLAG_DAMNED]) |
1322 | SET_FLAG (op, FLAG_DAMNED); |
1323 | op->set_flag (FLAG_DAMNED); |
1323 | if ((QUERY_FLAG (change, FLAG_CURSED) || QUERY_FLAG (change, FLAG_DAMNED)) && op->magic > 0) |
1324 | if ((change->flag [FLAG_CURSED] || change->flag [FLAG_DAMNED]) && op->magic > 0) |
1324 | set_abs_magic (op, -op->magic); |
1325 | set_abs_magic (op, -op->magic); |
1325 | |
1326 | |
1326 | if (QUERY_FLAG (change, FLAG_LIFESAVE)) |
1327 | if (change->flag [FLAG_LIFESAVE]) |
1327 | SET_FLAG (op, FLAG_LIFESAVE); |
1328 | op->set_flag (FLAG_LIFESAVE); |
1328 | if (QUERY_FLAG (change, FLAG_REFL_SPELL)) |
1329 | if (change->flag [FLAG_REFL_SPELL]) |
1329 | SET_FLAG (op, FLAG_REFL_SPELL); |
1330 | op->set_flag (FLAG_REFL_SPELL); |
1330 | if (QUERY_FLAG (change, FLAG_STEALTH)) |
1331 | if (change->flag [FLAG_STEALTH]) |
1331 | SET_FLAG (op, FLAG_STEALTH); |
1332 | op->set_flag (FLAG_STEALTH); |
1332 | if (QUERY_FLAG (change, FLAG_XRAYS)) |
1333 | if (change->flag [FLAG_XRAYS]) |
1333 | SET_FLAG (op, FLAG_XRAYS); |
1334 | op->set_flag (FLAG_XRAYS); |
1334 | if (QUERY_FLAG (change, FLAG_BLIND)) |
1335 | if (change->flag [FLAG_BLIND]) |
1335 | SET_FLAG (op, FLAG_BLIND); |
1336 | op->set_flag (FLAG_BLIND); |
1336 | if (QUERY_FLAG (change, FLAG_SEE_IN_DARK)) |
1337 | if (change->flag [FLAG_SEE_IN_DARK]) |
1337 | SET_FLAG (op, FLAG_SEE_IN_DARK); |
1338 | op->set_flag (FLAG_SEE_IN_DARK); |
1338 | if (QUERY_FLAG (change, FLAG_REFL_MISSILE)) |
1339 | if (change->flag [FLAG_REFL_MISSILE]) |
1339 | SET_FLAG (op, FLAG_REFL_MISSILE); |
1340 | op->set_flag (FLAG_REFL_MISSILE); |
1340 | if (QUERY_FLAG (change, FLAG_MAKE_INVIS)) |
1341 | if (change->flag [FLAG_MAKE_INVIS]) |
1341 | SET_FLAG (op, FLAG_MAKE_INVIS); |
1342 | op->set_flag (FLAG_MAKE_INVIS); |
1342 | |
1343 | |
1343 | if (QUERY_FLAG (change, FLAG_STAND_STILL)) |
1344 | if (change->flag [FLAG_STAND_STILL]) |
1344 | { |
1345 | { |
1345 | CLEAR_FLAG (op, FLAG_ANIMATE); |
1346 | op->clr_flag (FLAG_ANIMATE); |
1346 | /* so artifacts will join */ |
1347 | /* so artifacts will join */ |
1347 | if (!QUERY_FLAG (op, FLAG_ALIVE)) |
1348 | if (!op->flag [FLAG_ALIVE]) |
1348 | op->speed = 0.0; |
1349 | op->speed = 0.0; |
1349 | |
1350 | |
1350 | op->set_speed (op->speed); |
1351 | op->set_speed (op->speed); |
1351 | } |
1352 | } |
1352 | |
1353 | |
… | |
… | |
1369 | op->destroy_inv (false); |
1370 | op->destroy_inv (false); |
1370 | |
1371 | |
1371 | object *tmp = change->other_arch->instance (); |
1372 | object *tmp = change->other_arch->instance (); |
1372 | insert_ob_in_ob (tmp, op); |
1373 | insert_ob_in_ob (tmp, op); |
1373 | } |
1374 | } |
|
|
1375 | |
1374 | /* No harm setting this for potions/horns */ |
1376 | /* No harm setting this for potions/horns */ |
1375 | op->other_arch = change->other_arch; |
1377 | op->other_arch = change->other_arch; |
1376 | } |
1378 | } |
1377 | |
1379 | |
1378 | if (change->stats.hp < 0) |
1380 | if (change->stats.hp < 0) |
… | |
… | |
1525 | op->title = new_name; |
1527 | op->title = new_name; |
1526 | add_abilities (op, artifct); /* Give out the bonuses */ |
1528 | add_abilities (op, artifct); /* Give out the bonuses */ |
1527 | |
1529 | |
1528 | #if 0 /* Bit verbose, but keep it here until next time I need it... */ |
1530 | #if 0 /* Bit verbose, but keep it here until next time I need it... */ |
1529 | { |
1531 | { |
1530 | char identified = QUERY_FLAG (op, FLAG_IDENTIFIED); |
1532 | char identified = op->flag [FLAG_IDENTIFIED]; |
1531 | |
1533 | |
1532 | SET_FLAG (op, FLAG_IDENTIFIED); |
1534 | op->set_flag (FLAG_IDENTIFIED); |
1533 | LOG (llevDebug, "Generated artifact %s %s [%s]\n", op->name, op->title, describe_item (op, NULL)); |
1535 | LOG (llevDebug, "Generated artifact %s %s [%s]\n", op->name, op->title, describe_item (op, NULL)); |
1534 | if (!identified) |
1536 | if (!identified) |
1535 | CLEAR_FLAG (op, FLAG_IDENTIFIED); |
1537 | op->clr_flag (FLAG_IDENTIFIED); |
1536 | } |
1538 | } |
1537 | #endif |
1539 | #endif |
1538 | return; |
1540 | return; |
1539 | } |
1541 | } |
1540 | |
1542 | |
… | |
… | |
1651 | item->type = POISON; |
1653 | item->type = POISON; |
1652 | |
1654 | |
1653 | if (donor->attacktype & AT_ACID) |
1655 | if (donor->attacktype & AT_ACID) |
1654 | item->stats.hp = -1 * item->stats.food; |
1656 | item->stats.hp = -1 * item->stats.food; |
1655 | |
1657 | |
1656 | SET_FLAG (item, FLAG_NO_STEAL); |
1658 | item->set_flag (FLAG_NO_STEAL); |
1657 | } |
1659 | } |
1658 | } |
1660 | } |
1659 | |
1661 | |
1660 | static void |
1662 | static void |
1661 | free_treasurestruct (treasure *t) |
1663 | free_treasurestruct (treasure *t) |