… | |
… | |
53 | * subtype 5: arch or race |
53 | * subtype 5: arch or race |
54 | * subtype 7: all three |
54 | * subtype 7: all three |
55 | */ |
55 | */ |
56 | if (op->subtype) |
56 | if (op->subtype) |
57 | { |
57 | { |
58 | arch_flag = (op->subtype & 1); |
58 | arch_flag = op->subtype & 1; |
59 | name_flag = (op->subtype & 2); |
59 | name_flag = op->subtype & 2; |
60 | race_flag = (op->subtype & 4); |
60 | race_flag = op->subtype & 4; |
61 | } |
61 | } |
62 | else |
62 | else |
63 | { |
63 | { |
64 | arch_flag = 1; |
64 | arch_flag = 1; |
65 | name_flag = 1; |
65 | name_flag = 1; |
… | |
… | |
113 | { |
113 | { |
114 | if (operate_altar (altar, &money)) |
114 | if (operate_altar (altar, &money)) |
115 | { |
115 | { |
116 | identify (marked); |
116 | identify (marked); |
117 | |
117 | |
118 | buf.printf ("You have %s.\n\n", long_desc (marked, pl)); |
118 | buf.printf ("You have %s.\r", long_desc (marked, pl)); |
119 | if (marked->msg) |
119 | if (marked->msg) |
120 | buf << "The item has a story:\n\n" << marked->msg << "\n\n"; |
120 | buf << "The item has a story:\r" << marked->msg << "\n\n"; |
121 | |
121 | |
122 | return !money; |
122 | return !money; |
123 | } |
123 | } |
124 | } |
124 | } |
125 | |
125 | |
… | |
… | |
129 | { |
129 | { |
130 | if (operate_altar (altar, &money)) |
130 | if (operate_altar (altar, &money)) |
131 | { |
131 | { |
132 | identify (id); |
132 | identify (id); |
133 | |
133 | |
134 | buf.printf ("You have %s.\n\n", long_desc (id, pl)); |
134 | buf.printf ("You have %s.\r", long_desc (id, pl)); |
135 | if (id->msg) |
135 | if (id->msg) |
136 | buf << "The item has a story:\n\n" << id->msg << "\n\n"; |
136 | buf << "The item has a story:\r" << id->msg << "\n\n"; |
137 | |
137 | |
138 | /* If no more money, might as well quit now */ |
138 | /* If no more money, might as well quit now */ |
139 | if (!money || !check_altar_sacrifice (altar, money)) |
139 | if (!money || !check_altar_sacrifice (altar, money)) |
140 | break; |
140 | break; |
141 | } |
141 | } |
… | |
… | |
703 | weapon->last_eat++; |
703 | weapon->last_eat++; |
704 | weapon->item_power++; |
704 | weapon->item_power++; |
705 | improver->decrease (); |
705 | improver->decrease (); |
706 | return 1; |
706 | return 1; |
707 | } |
707 | } |
|
|
708 | |
708 | if (improver->stats.sp == IMPROVE_ENCHANT) |
709 | if (improver->stats.sp == IMPROVE_ENCHANT) |
709 | { |
710 | { |
710 | weapon->magic++; |
711 | weapon->magic++; |
711 | weapon->last_eat++; |
712 | weapon->last_eat++; |
712 | op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); |
713 | op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); |
… | |
… | |
767 | op->failmsg ("Something blocks the magic of the scroll!"); |
768 | op->failmsg ("Something blocks the magic of the scroll!"); |
768 | return 0; |
769 | return 0; |
769 | } |
770 | } |
770 | |
771 | |
771 | otmp = find_marked_object (op); |
772 | otmp = find_marked_object (op); |
|
|
773 | |
772 | if (!otmp) |
774 | if (!otmp) |
773 | { |
775 | { |
774 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
776 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
775 | return 0; |
777 | return 0; |
776 | } |
778 | } |
… | |
… | |
993 | item->nrof = give; |
995 | item->nrof = give; |
994 | |
996 | |
995 | if (nr) |
997 | if (nr) |
996 | item->nrof *= nr; |
998 | item->nrof *= nr; |
997 | |
999 | |
998 | if (is_in_shop (converter)) |
1000 | if (converter->flag [FLAG_PRECIOUS]) |
999 | SET_FLAG (item, FLAG_UNPAID); |
1001 | SET_FLAG (item, FLAG_UNPAID); |
|
|
1002 | |
|
|
1003 | if (is_in_shop (converter)) |
|
|
1004 | { |
|
|
1005 | // converters on shop floors don't work anymore, bug lets check for it |
|
|
1006 | // and report in case someone still does it. |
|
|
1007 | LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n", |
|
|
1008 | converter->debug_desc ()); |
|
|
1009 | SET_FLAG (item, FLAG_UNPAID); |
|
|
1010 | } |
1000 | else if (price_in < sint64 (item->nrof) * item->value) |
1011 | else if (price_in < sint64 (item->nrof) * item->value) |
1001 | { |
1012 | { |
1002 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1013 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
1003 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1014 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
1004 | /** |
1015 | /** |
1005 | * elmex: we are going to let the game continue, as the mapcreator |
1016 | * elmex: we are going to let the game continue, as the mapcreator |
1006 | * hopefully had something in mind when doing this. |
1017 | * hopefully had something in mind when doing this. |
1007 | */ |
1018 | */ |
1008 | } |
1019 | } |
1009 | |
1020 | |
1010 | SET_FLAG (item, FLAG_IDENTIFIED); |
1021 | // elmex: only identify if we need to, for example so that generated money doesn't |
|
|
1022 | // get an 'identified' flag so easily. |
|
|
1023 | if (need_identify (item)) |
|
|
1024 | identify (item); |
|
|
1025 | |
1011 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
1026 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
1012 | return 1; |
1027 | return 1; |
1013 | } |
1028 | } |
1014 | |
1029 | |
1015 | /** |
1030 | /** |
… | |
… | |
1147 | { |
1162 | { |
1148 | has_unpaid = true; |
1163 | has_unpaid = true; |
1149 | break; |
1164 | break; |
1150 | } |
1165 | } |
1151 | |
1166 | |
1152 | if (op->type != PLAYER) |
1167 | if (!op->is_player ()) |
1153 | { |
1168 | { |
1154 | /* Remove all the unpaid objects that may be carried here. |
1169 | /* Remove all the unpaid objects that may be carried here. |
1155 | * This could be pets or monsters that are somehow in |
1170 | * This could be pets or monsters that are somehow in |
1156 | * the shop. |
1171 | * the shop. |
1157 | */ |
1172 | */ |
… | |
… | |
1161 | |
1176 | |
1162 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
1177 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
1163 | { |
1178 | { |
1164 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
1179 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
1165 | |
1180 | |
|
|
1181 | if (i >= 0) |
1166 | tmp->remove (); |
1182 | tmp->move (i); |
1167 | |
|
|
1168 | if (i == -1) |
|
|
1169 | i = 0; |
|
|
1170 | |
|
|
1171 | tmp->map = op->map; |
|
|
1172 | tmp->x = op->x + freearr_x[i]; |
|
|
1173 | tmp->y = op->y + freearr_y[i]; |
|
|
1174 | insert_ob_in_map (tmp, op->map, op, 0); |
|
|
1175 | } |
1183 | } |
1176 | } |
1184 | } |
1177 | |
1185 | |
1178 | /* Don't teleport things like spell effects */ |
1186 | /* Don't teleport things like spell effects */ |
1179 | if (QUERY_FLAG (op, FLAG_NO_PICK)) |
1187 | if (QUERY_FLAG (op, FLAG_NO_PICK)) |
… | |
… | |
1190 | if (i != -1) |
1198 | if (i != -1) |
1191 | rv = transfer_ob (op, op->x + freearr_x[i], op->y + freearr_y[i], 0, shop_mat); |
1199 | rv = transfer_ob (op, op->x + freearr_x[i], op->y + freearr_y[i], 0, shop_mat); |
1192 | |
1200 | |
1193 | return 0; |
1201 | return 0; |
1194 | } |
1202 | } |
|
|
1203 | |
1195 | /* Removed code that checked for multipart objects - it appears that |
1204 | /* Removed code that checked for multipart objects - it appears that |
1196 | * the teleport function should be able to handle this just fine. |
1205 | * the teleport function should be able to handle this just fine. |
1197 | */ |
1206 | */ |
1198 | rv = teleport (shop_mat, SHOP_MAT, op); |
1207 | rv = teleport (shop_mat, SHOP_MAT, op); |
1199 | } |
1208 | } |
… | |
… | |
1254 | * Handles applying a sign. |
1263 | * Handles applying a sign. |
1255 | */ |
1264 | */ |
1256 | static void |
1265 | static void |
1257 | apply_sign (object *op, object *sign, int autoapply) |
1266 | apply_sign (object *op, object *sign, int autoapply) |
1258 | { |
1267 | { |
1259 | readable_message_type *msgType; |
1268 | if (sign->has_dialogue ()) |
|
|
1269 | { |
|
|
1270 | op->statusmsg (format ("Maybe you should I<talk> to the %s instead?", &sign->name)); |
|
|
1271 | return; |
|
|
1272 | } |
1260 | |
1273 | |
1261 | if (!sign->msg) |
1274 | if (!sign->msg) |
1262 | { |
1275 | { |
1263 | op->statusmsg ("Nothing is written on it."); |
1276 | op->contr->infobox (MSG_CHANNEL ("examine"), |
|
|
1277 | format ("T<%s>\n\n Nothing %sis written on it.", |
|
|
1278 | &sign->name, |
|
|
1279 | sign->name == sign->arch->name ? "" : "else ")); |
1264 | return; |
1280 | return; |
1265 | } |
1281 | } |
1266 | |
1282 | |
1267 | if (sign->stats.food) |
1283 | if (sign->stats.food) |
1268 | { |
1284 | { |
1269 | if (sign->last_eat >= sign->stats.food) |
1285 | if (sign->last_eat >= sign->stats.food) |
1270 | { |
1286 | { |
1271 | if (!sign->move_on) |
1287 | if (!sign->move_on) |
1272 | op->statusmsg ("You cannot read it anymore."); |
1288 | op->failmsg ("You cannot read it anymore."); |
1273 | |
1289 | |
1274 | return; |
1290 | return; |
1275 | } |
1291 | } |
1276 | |
1292 | |
1277 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
1293 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
… | |
… | |
1295 | if (sign->sound) |
1311 | if (sign->sound) |
1296 | ns->play_sound (sign->sound); |
1312 | ns->play_sound (sign->sound); |
1297 | else if (autoapply) |
1313 | else if (autoapply) |
1298 | ns->play_sound (sound_find ("msg_voice")); |
1314 | ns->play_sound (sound_find ("msg_voice")); |
1299 | |
1315 | |
1300 | if (ns->can_msg) |
|
|
1301 | op->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n\n\n%s", &sign->name, &sign->msg)); |
1316 | op->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n%s", &sign->name, &sign->msg)); |
1302 | else |
|
|
1303 | { |
|
|
1304 | msgType = get_readable_message_type (sign); |
|
|
1305 | const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg); |
|
|
1306 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, somemsg, &sign->msg); |
|
|
1307 | } |
|
|
1308 | } |
1317 | } |
|
|
1318 | } |
|
|
1319 | |
|
|
1320 | static void |
|
|
1321 | move_apply_hole (object *trap, object *victim) |
|
|
1322 | { |
|
|
1323 | /* Hole not open? */ |
|
|
1324 | if (trap->stats.wc > 0) |
|
|
1325 | return; |
|
|
1326 | |
|
|
1327 | /* Is this a multipart monster and not the head? If so, return. |
|
|
1328 | * Processing will happen if the head runs into the pit |
|
|
1329 | */ |
|
|
1330 | if (victim->head) |
|
|
1331 | return; |
|
|
1332 | |
|
|
1333 | // now find all possible locations and randomly pick one |
|
|
1334 | int dir = find_free_spot (victim, trap->map, EXIT_X (trap), EXIT_Y (trap), 0, |
|
|
1335 | trap->range >= 3 ? SIZEOFFREE3 + 1 |
|
|
1336 | : trap->range >= 2 ? SIZEOFFREE2 + 1 |
|
|
1337 | : trap->range >= 1 ? SIZEOFFREE1 + 1 |
|
|
1338 | : SIZEOFFREE0 + 1); |
|
|
1339 | |
|
|
1340 | if (dir < 0) |
|
|
1341 | return; |
|
|
1342 | |
|
|
1343 | victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
|
|
1344 | victim->statusmsg ("You fall through the hole!", NDI_RED); |
|
|
1345 | |
|
|
1346 | transfer_ob (victim, |
|
|
1347 | EXIT_X (trap) + freearr_x[dir], |
|
|
1348 | EXIT_Y (trap) + freearr_y[dir], |
|
|
1349 | 0, victim); |
1309 | } |
1350 | } |
1310 | |
1351 | |
1311 | /** |
1352 | /** |
1312 | * 'victim' moves onto 'trap' |
1353 | * 'victim' moves onto 'trap' |
1313 | * 'victim' leaves 'trap' |
1354 | * 'victim' leaves 'trap' |
… | |
… | |
1482 | case CHECK_INV: |
1523 | case CHECK_INV: |
1483 | check_inv (victim, trap); |
1524 | check_inv (victim, trap); |
1484 | goto leave; |
1525 | goto leave; |
1485 | |
1526 | |
1486 | case HOLE: |
1527 | case HOLE: |
1487 | /* Hole not open? */ |
1528 | move_apply_hole (trap, victim); |
1488 | if (trap->stats.wc > 0) |
|
|
1489 | goto leave; |
|
|
1490 | |
|
|
1491 | /* Is this a multipart monster and not the head? If so, return. |
|
|
1492 | * Processing will happen if the head runs into the pit |
|
|
1493 | */ |
|
|
1494 | if (victim->head) |
|
|
1495 | goto leave; |
|
|
1496 | |
|
|
1497 | victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
|
|
1498 | victim->statusmsg ("You fall through the hole!", NDI_RED); |
|
|
1499 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
|
|
1500 | goto leave; |
1529 | goto leave; |
1501 | |
1530 | |
1502 | case EXIT: |
1531 | case EXIT: |
1503 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1532 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1504 | { |
1533 | { |
… | |
… | |
1596 | |
1625 | |
1597 | readable_message_type *msgType = get_readable_message_type (tmp); |
1626 | readable_message_type *msgType = get_readable_message_type (tmp); |
1598 | |
1627 | |
1599 | if (player *pl = op->contr) |
1628 | if (player *pl = op->contr) |
1600 | if (client *ns = pl->ns) |
1629 | if (client *ns = pl->ns) |
1601 | if (ns->can_msg) |
|
|
1602 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1630 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
1603 | else |
|
|
1604 | draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, |
|
|
1605 | msgType->message_type, msgType->message_subtype, |
|
|
1606 | "You open the %s and start reading.\n%s", (char *)"%s\n%s", |
|
|
1607 | long_desc (tmp, op), &tmp->msg); |
|
|
1608 | |
1631 | |
1609 | /* gain xp from reading */ |
1632 | /* gain xp from reading */ |
1610 | if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT)) |
1633 | if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT)) |
1611 | { /* only if not read before */ |
1634 | { /* only if not read before */ |
1612 | int exp_gain = calc_skill_exp (op, tmp, skill_ob); |
1635 | int exp_gain = calc_skill_exp (op, tmp, skill_ob); |
… | |
… | |
1935 | if (op->destroyed () || tmp->destroyed ()) |
1958 | if (op->destroyed () || tmp->destroyed ()) |
1936 | break; |
1959 | break; |
1937 | } |
1960 | } |
1938 | |
1961 | |
1939 | if (!tmp->destroyed () && !tmp->inv) |
1962 | if (!tmp->destroyed () && !tmp->inv) |
1940 | tmp->decrease (); |
1963 | tmp->decrease (true); |
1941 | } |
1964 | } |
1942 | |
1965 | |
1943 | /** |
1966 | /** |
1944 | * op eats food. |
1967 | * op eats food. |
1945 | * If player, takes care of messages and dragon special food. |
1968 | * If player, takes care of messages and dragon special food. |
… | |
… | |
2140 | op->statusmsg (buf); |
2163 | op->statusmsg (buf); |
2141 | |
2164 | |
2142 | /* now choose a winner if we have any */ |
2165 | /* now choose a winner if we have any */ |
2143 | i = -1; |
2166 | i = -1; |
2144 | if (winners > 0) |
2167 | if (winners > 0) |
2145 | i = atnr_winner[RANDOM () % winners]; |
2168 | i = atnr_winner [rndm (winners)]; |
2146 | |
2169 | |
2147 | if (i >= 0 && i < NROFATTACKS && skin->resist[i] < 95) |
2170 | if (i >= 0 && i < NROFATTACKS && skin->resist[i] < 95) |
2148 | { |
2171 | { |
2149 | /* resistance increased! */ |
2172 | /* resistance increased! */ |
2150 | skin->resist[i]++; |
2173 | skin->resist[i]++; |
… | |
… | |
2630 | * person moving on it, also activate. Added code to make it |
2653 | * person moving on it, also activate. Added code to make it |
2631 | * so that at least one of players movement types be that which |
2654 | * so that at least one of players movement types be that which |
2632 | * the item needs. |
2655 | * the item needs. |
2633 | */ |
2656 | */ |
2634 | if (!tmp->invisible || (tmp->move_on & pl->move_type)) |
2657 | if (!tmp->invisible || (tmp->move_on & pl->move_type)) |
2635 | { |
|
|
2636 | if (player_apply (pl, tmp, 0, 1) == 1) |
2658 | if (player_apply (pl, tmp, 0, 1) == 1) |
2637 | return; |
2659 | return; |
2638 | } |
2660 | |
2639 | if (floors >= 2) |
2661 | if (floors >= 2) |
2640 | return; /* process at most two floor objects */ |
2662 | return; /* process at most two floor objects */ |
2641 | } |
2663 | } |
2642 | } |
2664 | } |
2643 | |
2665 | |
… | |
… | |
2737 | op->destroy (); |
2759 | op->destroy (); |
2738 | who->insert (tmp2); |
2760 | who->insert (tmp2); |
2739 | who->update_stats (); |
2761 | who->update_stats (); |
2740 | |
2762 | |
2741 | if (who->contr) |
2763 | if (who->contr) |
2742 | { |
|
|
2743 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2764 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
2744 | { |
2765 | { |
2745 | who->failmsg ("Oops, it feels deadly cold!"); |
2766 | who->failmsg ("Oops, it feels deadly cold!"); |
2746 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2767 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
2747 | } |
2768 | } |
2748 | } |
|
|
2749 | } |
2769 | } |
2750 | |
2770 | |
2751 | return 1; /* otherwise, an attempt to drop causes problems */ |
2771 | return 1; /* otherwise, an attempt to drop causes problems */ |
2752 | |
2772 | |
2753 | case BOW: |
2773 | case BOW: |
… | |
… | |
3275 | who->update_stats (); |
3295 | who->update_stats (); |
3276 | |
3296 | |
3277 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3297 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3278 | if (who->type == PLAYER) |
3298 | if (who->type == PLAYER) |
3279 | { |
3299 | { |
3280 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>"); |
3300 | who->failmsg ("Oops, it feels deadly cold! H<Maybe it wasn't such a bright (hrhrhr) idea to apply this cursed or damned item.>"); |
3281 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3301 | SET_FLAG (tmp2, FLAG_KNOWN_CURSED); |
3282 | } |
3302 | } |
3283 | |
3303 | |
3284 | return 0; |
3304 | return 0; |
3285 | |
3305 | |
… | |
… | |
3463 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3483 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
3464 | if (who->type == PLAYER) |
3484 | if (who->type == PLAYER) |
3465 | { |
3485 | { |
3466 | who->failmsg ( |
3486 | who->failmsg ( |
3467 | "Oops, it feels deadly cold! " |
3487 | "Oops, it feels deadly cold! " |
3468 | "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>" |
3488 | "H<Maybe it wasn't such a bright idea to apply this cursed or damned item.>" |
3469 | ); |
3489 | ); |
3470 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3490 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
3471 | } |
3491 | } |
3472 | |
3492 | |
3473 | if (object *pl = op->visible_to ()) |
3493 | if (object *pl = op->visible_to ()) |
… | |
… | |
3493 | int |
3513 | int |
3494 | auto_apply (object *op) |
3514 | auto_apply (object *op) |
3495 | { |
3515 | { |
3496 | object *tmp = NULL, *tmp2; |
3516 | object *tmp = NULL, *tmp2; |
3497 | int i; |
3517 | int i; |
|
|
3518 | |
|
|
3519 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
3498 | |
3520 | |
3499 | switch (op->type) |
3521 | switch (op->type) |
3500 | { |
3522 | { |
3501 | case SHOP_FLOOR: |
3523 | case SHOP_FLOOR: |
3502 | if (!op->has_random_items ()) |
3524 | if (!op->has_random_items ()) |
… | |
… | |
3504 | |
3526 | |
3505 | do |
3527 | do |
3506 | { |
3528 | { |
3507 | i = 10; /* let's give it 10 tries */ |
3529 | i = 10; /* let's give it 10 tries */ |
3508 | while ((tmp = generate_treasure (op->randomitems, |
3530 | while ((tmp = generate_treasure (op->randomitems, |
3509 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3531 | op->stats.exp |
|
|
3532 | ? (int) op->stats.exp |
|
|
3533 | : max (op->map->difficulty, 5))) |
|
|
3534 | == NULL && --i); |
|
|
3535 | |
3510 | if (tmp == NULL) |
3536 | if (tmp == NULL) |
3511 | return 0; |
3537 | return 0; |
|
|
3538 | |
3512 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3539 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3513 | { |
3540 | { |
3514 | tmp->destroy (); |
3541 | tmp->destroy (); |
3515 | tmp = NULL; |
3542 | tmp = NULL; |
3516 | } |
3543 | } |
… | |
… | |
3519 | |
3546 | |
3520 | tmp->x = op->x; |
3547 | tmp->x = op->x; |
3521 | tmp->y = op->y; |
3548 | tmp->y = op->y; |
3522 | SET_FLAG (tmp, FLAG_UNPAID); |
3549 | SET_FLAG (tmp, FLAG_UNPAID); |
3523 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3550 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3524 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
|
|
3525 | identify (tmp); |
3551 | identify (tmp); |
3526 | break; |
3552 | break; |
3527 | |
3553 | |
3528 | case TREASURE: |
3554 | case TREASURE: |
3529 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3555 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
… | |
… | |
3536 | /* If we generated an object and put it in this object inventory, |
3562 | /* If we generated an object and put it in this object inventory, |
3537 | * move it to the parent object as the current object is about |
3563 | * move it to the parent object as the current object is about |
3538 | * to disappear. An example of this item is the random_* stuff |
3564 | * to disappear. An example of this item is the random_* stuff |
3539 | * that is put inside other objects. |
3565 | * that is put inside other objects. |
3540 | */ |
3566 | */ |
3541 | for (tmp = op->inv; tmp; tmp = tmp2) |
|
|
3542 | { |
|
|
3543 | tmp2 = tmp->below; |
|
|
3544 | tmp->remove (); |
|
|
3545 | |
|
|
3546 | if (op->env) |
3567 | if (op->env) |
3547 | insert_ob_in_ob (tmp, op->env); |
3568 | while (op->inv) |
3548 | else |
3569 | op->env->insert (op->inv); |
3549 | tmp->destroy (); |
|
|
3550 | } |
|
|
3551 | |
3570 | |
3552 | op->destroy (); |
3571 | op->destroy (); |
3553 | break; |
3572 | break; |
3554 | } |
3573 | } |
3555 | return tmp ? 1 : 0; |
3574 | |
|
|
3575 | return !!tmp; |
3556 | } |
3576 | } |
3557 | |
3577 | |
3558 | /** |
3578 | /** |
3559 | * fix_auto_apply goes through the entire map every time a map |
3579 | * fix_auto_apply goes through the entire map every time a map |
3560 | * is loaded or swapped in and performs special actions for |
3580 | * is loaded or swapped in and performs special actions for |
… | |
… | |
3574 | |
3594 | |
3575 | if (tmp->inv) |
3595 | if (tmp->inv) |
3576 | { |
3596 | { |
3577 | object *invtmp, *invnext; |
3597 | object *invtmp, *invnext; |
3578 | |
3598 | |
3579 | for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) |
3599 | for (invtmp = tmp->inv; invtmp; invtmp = invnext) |
3580 | { |
3600 | { |
3581 | invnext = invtmp->below; |
3601 | invnext = invtmp->below; |
3582 | |
3602 | |
3583 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3603 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3584 | auto_apply (invtmp); |
3604 | auto_apply (invtmp); |
3585 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3605 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3586 | { |
3606 | { |
3587 | while ((invtmp->stats.hp--) > 0) |
3607 | while (invtmp->stats.hp-- > 0) |
3588 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3608 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3589 | |
3609 | |
3590 | invtmp->randomitems = NULL; |
3610 | invtmp->randomitems = NULL; |
3591 | } |
3611 | } |
3592 | else if (invtmp && invtmp->arch |
3612 | else if (invtmp && invtmp->arch |