… | |
… | |
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 | } |
… | |
… | |
160 | * matching item. |
160 | * matching item. |
161 | **/ |
161 | **/ |
162 | void |
162 | void |
163 | handle_apply_yield (object *tmp) |
163 | handle_apply_yield (object *tmp) |
164 | { |
164 | { |
165 | const char *yield; |
165 | if (shstr yield = tmp->kv (shstr_on_use_yield)) |
166 | |
|
|
167 | yield = get_ob_key_value (tmp, "on_use_yield"); |
|
|
168 | |
|
|
169 | if (yield) |
|
|
170 | get_archetype (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR); |
166 | archetype::get (yield)->insert_at (tmp, tmp, INS_BELOW_ORIGINATOR); |
171 | } |
167 | } |
172 | |
168 | |
173 | /** |
169 | /** |
174 | * Handles applying a potion. |
170 | * Handles applying a potion. |
175 | */ |
171 | */ |
… | |
… | |
612 | weapon->stats.exp || /* speed */ |
608 | weapon->stats.exp || /* speed */ |
613 | weapon->stats.ac) /* AC - only taifu's I think */ |
609 | weapon->stats.ac) /* AC - only taifu's I think */ |
614 | { |
610 | { |
615 | op->failmsg ("You cannot prepare magic weapons. " |
611 | op->failmsg ("You cannot prepare magic weapons. " |
616 | "H<A weapon is considered magical if it changes regeneration, " |
612 | "H<A weapon is considered magical if it changes regeneration, " |
617 | "speed or ac.>"); |
613 | "speed or ac, or has other protections.>"); |
618 | return 0; |
614 | return 0; |
619 | } |
615 | } |
620 | |
616 | |
621 | sacrifice_count = check_sacrifice (op, improver); |
617 | sacrifice_count = check_sacrifice (op, improver); |
622 | if (sacrifice_count <= 0) |
618 | if (sacrifice_count <= 0) |
… | |
… | |
707 | weapon->last_eat++; |
703 | weapon->last_eat++; |
708 | weapon->item_power++; |
704 | weapon->item_power++; |
709 | improver->decrease (); |
705 | improver->decrease (); |
710 | return 1; |
706 | return 1; |
711 | } |
707 | } |
|
|
708 | |
712 | if (improver->stats.sp == IMPROVE_ENCHANT) |
709 | if (improver->stats.sp == IMPROVE_ENCHANT) |
713 | { |
710 | { |
714 | weapon->magic++; |
711 | weapon->magic++; |
715 | weapon->last_eat++; |
712 | weapon->last_eat++; |
716 | op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); |
713 | op->statusmsg (format ("Weapon magic increased to %d.", weapon->magic)); |
… | |
… | |
771 | op->failmsg ("Something blocks the magic of the scroll!"); |
768 | op->failmsg ("Something blocks the magic of the scroll!"); |
772 | return 0; |
769 | return 0; |
773 | } |
770 | } |
774 | |
771 | |
775 | otmp = find_marked_object (op); |
772 | otmp = find_marked_object (op); |
|
|
773 | |
776 | if (!otmp) |
774 | if (!otmp) |
777 | { |
775 | { |
778 | 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.>"); |
779 | return 0; |
777 | return 0; |
780 | } |
778 | } |
… | |
… | |
974 | ob_to_copy = converter->inv; |
972 | ob_to_copy = converter->inv; |
975 | for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) |
973 | for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) |
976 | if (rndm (0, i) == 0) |
974 | if (rndm (0, i) == 0) |
977 | ob_to_copy = ob; |
975 | ob_to_copy = ob; |
978 | |
976 | |
979 | item = object_create_clone (ob_to_copy); |
977 | item = ob_to_copy->deep_clone (); |
980 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
978 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
981 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
979 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
982 | } |
980 | } |
983 | else |
981 | else |
984 | { |
982 | { |
… | |
… | |
1009 | * elmex: we are going to let the game continue, as the mapcreator |
1007 | * elmex: we are going to let the game continue, as the mapcreator |
1010 | * hopefully had something in mind when doing this. |
1008 | * hopefully had something in mind when doing this. |
1011 | */ |
1009 | */ |
1012 | } |
1010 | } |
1013 | |
1011 | |
1014 | SET_FLAG (item, FLAG_IDENTIFIED); |
1012 | // elmex: only identify if we need to, for example so that generated money doesn't |
|
|
1013 | // get an 'identified' flag so easily. |
|
|
1014 | if (need_identify (item)) |
|
|
1015 | identify (item); |
|
|
1016 | |
1015 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
1017 | insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); |
1016 | return 1; |
1018 | return 1; |
1017 | } |
1019 | } |
1018 | |
1020 | |
1019 | /** |
1021 | /** |
… | |
… | |
1258 | * Handles applying a sign. |
1260 | * Handles applying a sign. |
1259 | */ |
1261 | */ |
1260 | static void |
1262 | static void |
1261 | apply_sign (object *op, object *sign, int autoapply) |
1263 | apply_sign (object *op, object *sign, int autoapply) |
1262 | { |
1264 | { |
1263 | readable_message_type *msgType; |
1265 | if (sign->has_dialogue ()) |
|
|
1266 | { |
|
|
1267 | op->statusmsg (form ("Maybe you should I<talk> to the %s instead?", &sign->name)); |
|
|
1268 | return; |
|
|
1269 | } |
1264 | |
1270 | |
1265 | if (!sign->msg) |
1271 | if (!sign->msg) |
1266 | { |
1272 | { |
1267 | op->statusmsg ("Nothing is written on it."); |
1273 | op->statusmsg ("Nothing is written on it."); |
1268 | return; |
1274 | return; |
… | |
… | |
1303 | |
1309 | |
1304 | if (ns->can_msg) |
1310 | if (ns->can_msg) |
1305 | op->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n\n\n%s", &sign->name, &sign->msg)); |
1311 | op->contr->infobox (MSG_CHANNEL ("examine"), format ("T<%s>\n\n\n\n%s", &sign->name, &sign->msg)); |
1306 | else |
1312 | else |
1307 | { |
1313 | { |
1308 | msgType = get_readable_message_type (sign); |
1314 | readable_message_type *msgType = get_readable_message_type (sign); |
1309 | const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg); |
1315 | const char *somemsg = format ("%u %s", autoapply ? 1 : 0, &sign->msg); |
1310 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, somemsg, &sign->msg); |
1316 | draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, somemsg, &sign->msg); |
1311 | } |
1317 | } |
1312 | } |
1318 | } |
|
|
1319 | } |
|
|
1320 | |
|
|
1321 | static void |
|
|
1322 | move_apply_hole (object *trap, object *victim) |
|
|
1323 | { |
|
|
1324 | /* Hole not open? */ |
|
|
1325 | if (trap->stats.wc > 0) |
|
|
1326 | return; |
|
|
1327 | |
|
|
1328 | /* Is this a multipart monster and not the head? If so, return. |
|
|
1329 | * Processing will happen if the head runs into the pit |
|
|
1330 | */ |
|
|
1331 | if (victim->head) |
|
|
1332 | return; |
|
|
1333 | |
|
|
1334 | // now find all possible locations and randomly pick one |
|
|
1335 | int dir = find_free_spot (victim, trap->map, EXIT_X (trap), EXIT_Y (trap), 0, |
|
|
1336 | trap->range >= 3 ? SIZEOFFREE3 + 1 |
|
|
1337 | : trap->range >= 2 ? SIZEOFFREE2 + 1 |
|
|
1338 | : trap->range >= 1 ? SIZEOFFREE1 + 1 |
|
|
1339 | : SIZEOFFREE0 + 1); |
|
|
1340 | |
|
|
1341 | if (dir < 0) |
|
|
1342 | return; |
|
|
1343 | |
|
|
1344 | victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
|
|
1345 | victim->statusmsg ("You fall through the hole!", NDI_RED); |
|
|
1346 | |
|
|
1347 | transfer_ob (victim, |
|
|
1348 | EXIT_X (trap) + freearr_x[dir], |
|
|
1349 | EXIT_Y (trap) + freearr_y[dir], |
|
|
1350 | 0, victim); |
1313 | } |
1351 | } |
1314 | |
1352 | |
1315 | /** |
1353 | /** |
1316 | * 'victim' moves onto 'trap' |
1354 | * 'victim' moves onto 'trap' |
1317 | * 'victim' leaves 'trap' |
1355 | * 'victim' leaves 'trap' |
… | |
… | |
1466 | |
1504 | |
1467 | case CONVERTER: |
1505 | case CONVERTER: |
1468 | if (convert_item (victim, trap) < 0) |
1506 | if (convert_item (victim, trap) < 0) |
1469 | { |
1507 | { |
1470 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
1508 | originator->failmsg (format ("The %s seems to be broken!", query_name (trap))); |
1471 | get_archetype ("burnout")->insert_at (trap, trap); |
1509 | archetype::get (shstr_burnout)->insert_at (trap, trap); |
1472 | } |
1510 | } |
1473 | |
1511 | |
1474 | goto leave; |
1512 | goto leave; |
1475 | |
1513 | |
1476 | case TRIGGER_BUTTON: |
1514 | case TRIGGER_BUTTON: |
… | |
… | |
1486 | case CHECK_INV: |
1524 | case CHECK_INV: |
1487 | check_inv (victim, trap); |
1525 | check_inv (victim, trap); |
1488 | goto leave; |
1526 | goto leave; |
1489 | |
1527 | |
1490 | case HOLE: |
1528 | case HOLE: |
1491 | /* Hole not open? */ |
1529 | move_apply_hole (trap, victim); |
1492 | if (trap->stats.wc > 0) |
|
|
1493 | goto leave; |
|
|
1494 | |
|
|
1495 | /* Is this a multipart monster and not the head? If so, return. |
|
|
1496 | * Processing will happen if the head runs into the pit |
|
|
1497 | */ |
|
|
1498 | if (victim->head) |
|
|
1499 | goto leave; |
|
|
1500 | |
|
|
1501 | victim->play_sound (trap->sound ? trap->sound : sound_find ("fall_hole")); |
|
|
1502 | victim->statusmsg ("You fall through the hole!", NDI_RED); |
|
|
1503 | transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); |
|
|
1504 | goto leave; |
1530 | goto leave; |
1505 | |
1531 | |
1506 | case EXIT: |
1532 | case EXIT: |
1507 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1533 | if (victim->type == PLAYER && EXIT_PATH (trap)) |
1508 | { |
1534 | { |
… | |
… | |
2213 | |
2239 | |
2214 | op->statusmsg ("Applying armour enchantment."); |
2240 | op->statusmsg ("Applying armour enchantment."); |
2215 | improve_armour (op, tmp, armor); |
2241 | improve_armour (op, tmp, armor); |
2216 | } |
2242 | } |
2217 | |
2243 | |
2218 | extern void |
2244 | void |
2219 | apply_poison (object *op, object *tmp) |
2245 | apply_poison (object *op, object *tmp) |
2220 | { |
2246 | { |
|
|
2247 | // need to do it now when it is still on the map |
|
|
2248 | handle_apply_yield (tmp); |
|
|
2249 | |
|
|
2250 | object *poison = tmp->split (1); |
|
|
2251 | |
2221 | if (op->type == PLAYER) |
2252 | if (op->type == PLAYER) |
2222 | { |
2253 | { |
2223 | op->contr->play_sound (sound_find ("drink_poison")); |
2254 | op->contr->play_sound (sound_find ("drink_poison")); |
2224 | op->failmsg ("Yech! That tasted poisonous!"); |
2255 | op->failmsg ("Yech! That tasted poisonous!"); |
2225 | strcpy (op->contr->killer, "poisonous booze"); |
2256 | op->contr->killer = poison; |
2226 | } |
2257 | } |
2227 | |
2258 | |
2228 | if (tmp->stats.hp > 0) |
2259 | if (poison->stats.hp > 0) |
2229 | { |
2260 | { |
2230 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); |
2261 | LOG (llevDebug, "Trying to poison player/monster for %d hp\n", poison->stats.hp); |
2231 | hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); |
2262 | hit_player (op, poison->stats.hp, tmp, AT_POISON, 1); |
2232 | } |
2263 | } |
2233 | |
2264 | |
2234 | op->stats.food -= op->stats.food / 4; |
2265 | op->stats.food -= op->stats.food / 4; |
2235 | handle_apply_yield (tmp); |
2266 | poison->destroy (); |
2236 | tmp->decrease (); |
|
|
2237 | } |
2267 | } |
2238 | |
2268 | |
2239 | /** |
2269 | /** |
2240 | * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
2270 | * This function return true if the exit is not a 2 ways one or it is 2 ways, valid exit. |
2241 | * A valid 2 way exit means: |
2271 | * A valid 2 way exit means: |
… | |
… | |
2343 | * them in this function - they are passed to apply_special |
2373 | * them in this function - they are passed to apply_special |
2344 | */ |
2374 | */ |
2345 | int |
2375 | int |
2346 | manual_apply (object *op, object *tmp, int aflag) |
2376 | manual_apply (object *op, object *tmp, int aflag) |
2347 | { |
2377 | { |
2348 | if (tmp->head) |
|
|
2349 | tmp = tmp->head; |
2378 | tmp = tmp->head_ (); |
2350 | |
2379 | |
2351 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2380 | if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) |
2352 | { |
2381 | { |
2353 | if (op->type == PLAYER) |
2382 | if (op->type == PLAYER) |
2354 | { |
2383 | { |
… | |
… | |
2562 | default: |
2591 | default: |
2563 | return 0; |
2592 | return 0; |
2564 | } |
2593 | } |
2565 | } |
2594 | } |
2566 | |
2595 | |
2567 | |
|
|
2568 | /* quiet suppresses the "don't know how to apply" and "you must get it first" |
2596 | /* quiet suppresses the "don't know how to apply" and "you must get it first" |
2569 | * messages as needed by player_apply_below(). But there can still be |
2597 | * messages as needed by player_apply_below(). But there can still be |
2570 | * "but you are floating high above the ground" messages. |
2598 | * "but you are floating high above the ground" messages. |
2571 | * |
2599 | * |
2572 | * Same return value as apply() function. |
2600 | * Same return value as apply() function. |
2573 | */ |
2601 | */ |
2574 | int |
2602 | int |
2575 | player_apply (object *pl, object *op, int aflag, int quiet) |
2603 | player_apply (object *pl, object *op, int aflag, int quiet) |
2576 | { |
2604 | { |
2577 | int tmp; |
|
|
2578 | |
|
|
2579 | if (op->env && (pl->move_type & MOVE_FLYING)) |
2605 | if (!op->env && (pl->move_type & MOVE_FLYING)) |
2580 | { |
2606 | { |
2581 | /* player is flying and applying object not in inventory */ |
2607 | /* player is flying and applying object not in inventory */ |
2582 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2608 | if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) |
2583 | { |
2609 | { |
2584 | pl->failmsg ("But you are floating high above the ground! H<You have to stop levitating first, if you can.>"); |
2610 | pl->failmsg ("But you are floating high above the ground! " |
|
|
2611 | "H<You have to stop levitating first, if you can, either by using your levitation skill, " |
|
|
2612 | "or waiting till the levitation effect wears off.>"); |
2585 | return 0; |
2613 | return 0; |
2586 | } |
2614 | } |
2587 | } |
2615 | } |
2588 | |
2616 | |
2589 | pl->contr->last_used = op; |
2617 | pl->contr->last_used = op; |
2590 | |
2618 | |
2591 | tmp = manual_apply (pl, op, aflag); |
2619 | int tmp = manual_apply (pl, op, aflag); |
|
|
2620 | |
2592 | if (!quiet) |
2621 | if (!quiet) |
2593 | { |
2622 | { |
2594 | if (tmp == 0) |
2623 | if (tmp == 0) |
2595 | pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op))); |
2624 | pl->statusmsg (format ("I don't know how to apply the %s.", query_name (op))); |
2596 | else if (tmp == 2) |
2625 | else if (tmp == 2) |
… | |
… | |
2688 | break; |
2717 | break; |
2689 | |
2718 | |
2690 | case SKILL: |
2719 | case SKILL: |
2691 | if (who->contr) |
2720 | if (who->contr) |
2692 | { |
2721 | { |
|
|
2722 | if (IS_COMBAT_SKILL (op->subtype)) |
|
|
2723 | who->change_weapon (who->contr->combat_ob = 0); |
|
|
2724 | else if (IS_RANGED_SKILL (op->subtype)) |
|
|
2725 | who->change_weapon (who->contr->ranged_ob = 0); |
|
|
2726 | |
2693 | if (!op->invisible) |
2727 | if (op->invisible) |
|
|
2728 | who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
|
|
2729 | else |
2694 | who->statusmsg (format ("You stop using the %s.", query_name (op))); |
2730 | who->statusmsg (format ("You stop using the %s.", query_name (op))); |
2695 | else |
|
|
2696 | who->statusmsg (format ("You can no longer use the skill: %s.", &op->skill)); |
|
|
2697 | } |
2731 | } |
2698 | |
2732 | |
2699 | change_abil (who, op); |
2733 | change_abil (who, op); |
2700 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2734 | CLEAR_FLAG (who, FLAG_READY_SKILL); |
2701 | break; |
2735 | break; |
… | |
… | |
2780 | default: |
2814 | default: |
2781 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
2815 | who->statusmsg (format ("You unapply %s.", query_name (op))); |
2782 | break; |
2816 | break; |
2783 | } |
2817 | } |
2784 | |
2818 | |
|
|
2819 | if (aflags & AP_NO_MERGE || !merge_ob (op, 0)) |
|
|
2820 | if (object *pl = op->visible_to ()) |
|
|
2821 | esrv_send_item (pl, op); |
|
|
2822 | |
2785 | who->update_stats (); |
2823 | who->update_stats (); |
2786 | |
|
|
2787 | if (!(aflags & AP_NO_MERGE)) |
|
|
2788 | merge_ob (op, 0); |
|
|
2789 | |
2824 | |
2790 | return 0; |
2825 | return 0; |
2791 | } |
2826 | } |
2792 | |
2827 | |
2793 | /** |
2828 | /** |
… | |
… | |
3091 | return 1; |
3126 | return 1; |
3092 | } |
3127 | } |
3093 | |
3128 | |
3094 | return unapply_special (who, op, aflags); |
3129 | return unapply_special (who, op, aflags); |
3095 | } |
3130 | } |
3096 | |
|
|
3097 | if (basic_flag == AP_UNAPPLY) |
3131 | else if (basic_flag == AP_UNAPPLY) |
3098 | return 0; |
3132 | return 0; |
3099 | |
3133 | |
3100 | // if the item is combat/ranged, wield the relevant slot first |
3134 | // if the item is combat/ranged, wield the relevant slot first |
3101 | // to resolve conflicts. |
3135 | // to resolve conflicts. |
3102 | if (player *pl = who->contr) |
3136 | if (player *pl = who->contr) |
… | |
… | |
3182 | switch (op->type) |
3216 | switch (op->type) |
3183 | { |
3217 | { |
3184 | case WEAPON: |
3218 | case WEAPON: |
3185 | if (!check_weapon_power (who, op->last_eat)) |
3219 | if (!check_weapon_power (who, op->last_eat)) |
3186 | { |
3220 | { |
3187 | op->failmsg ("This weapon is too powerful for you to use. It would consume your soul!." LACK_ITEM_POWER); |
3221 | op->failmsg ("This weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER); |
3188 | |
3222 | |
3189 | if (tmp) |
3223 | if (tmp) |
3190 | insert_ob_in_ob (tmp, who); |
3224 | insert_ob_in_ob (tmp, who); |
3191 | |
3225 | |
3192 | return 1; |
3226 | return 1; |
… | |
… | |
3490 | auto_apply (object *op) |
3524 | auto_apply (object *op) |
3491 | { |
3525 | { |
3492 | object *tmp = NULL, *tmp2; |
3526 | object *tmp = NULL, *tmp2; |
3493 | int i; |
3527 | int i; |
3494 | |
3528 | |
|
|
3529 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
|
|
3530 | |
3495 | switch (op->type) |
3531 | switch (op->type) |
3496 | { |
3532 | { |
3497 | case SHOP_FLOOR: |
3533 | case SHOP_FLOOR: |
3498 | if (!op->has_random_items ()) |
3534 | if (!op->has_random_items ()) |
3499 | return 0; |
3535 | return 0; |
3500 | |
3536 | |
3501 | do |
3537 | do |
3502 | { |
3538 | { |
3503 | i = 10; /* let's give it 10 tries */ |
3539 | i = 10; /* let's give it 10 tries */ |
3504 | while ((tmp = generate_treasure (op->randomitems, |
3540 | while ((tmp = generate_treasure (op->randomitems, |
3505 | op->stats.exp ? (int) op->stats.exp : MAX (op->map->difficulty, 5))) == NULL && --i); |
3541 | op->stats.exp |
|
|
3542 | ? (int) op->stats.exp |
|
|
3543 | : max (op->map->difficulty, 5))) |
|
|
3544 | == NULL && --i); |
|
|
3545 | |
3506 | if (tmp == NULL) |
3546 | if (tmp == NULL) |
3507 | return 0; |
3547 | return 0; |
|
|
3548 | |
3508 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3549 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3509 | { |
3550 | { |
3510 | tmp->destroy (); |
3551 | tmp->destroy (); |
3511 | tmp = NULL; |
3552 | tmp = NULL; |
3512 | } |
3553 | } |
… | |
… | |
3515 | |
3556 | |
3516 | tmp->x = op->x; |
3557 | tmp->x = op->x; |
3517 | tmp->y = op->y; |
3558 | tmp->y = op->y; |
3518 | SET_FLAG (tmp, FLAG_UNPAID); |
3559 | SET_FLAG (tmp, FLAG_UNPAID); |
3519 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3560 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3520 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
|
|
3521 | identify (tmp); |
3561 | identify (tmp); |
3522 | break; |
3562 | break; |
3523 | |
3563 | |
3524 | case TREASURE: |
3564 | case TREASURE: |
3525 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3565 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
… | |
… | |
3546 | } |
3586 | } |
3547 | |
3587 | |
3548 | op->destroy (); |
3588 | op->destroy (); |
3549 | break; |
3589 | break; |
3550 | } |
3590 | } |
3551 | return tmp ? 1 : 0; |
3591 | |
|
|
3592 | return !!tmp; |
3552 | } |
3593 | } |
3553 | |
3594 | |
3554 | /** |
3595 | /** |
3555 | * fix_auto_apply goes through the entire map every time a map |
3596 | * fix_auto_apply goes through the entire map every time a map |
3556 | * is loaded or swapped in and performs special actions for |
3597 | * is loaded or swapped in and performs special actions for |
… | |
… | |
3570 | |
3611 | |
3571 | if (tmp->inv) |
3612 | if (tmp->inv) |
3572 | { |
3613 | { |
3573 | object *invtmp, *invnext; |
3614 | object *invtmp, *invnext; |
3574 | |
3615 | |
3575 | for (invtmp = tmp->inv; invtmp != NULL; invtmp = invnext) |
3616 | for (invtmp = tmp->inv; invtmp; invtmp = invnext) |
3576 | { |
3617 | { |
3577 | invnext = invtmp->below; |
3618 | invnext = invtmp->below; |
3578 | |
3619 | |
3579 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3620 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3580 | auto_apply (invtmp); |
3621 | auto_apply (invtmp); |
3581 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3622 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3582 | { |
3623 | { |
3583 | while ((invtmp->stats.hp--) > 0) |
3624 | while (invtmp->stats.hp-- > 0) |
3584 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3625 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3585 | |
3626 | |
3586 | invtmp->randomitems = NULL; |
3627 | invtmp->randomitems = NULL; |
3587 | } |
3628 | } |
3588 | else if (invtmp && invtmp->arch |
3629 | else if (invtmp && invtmp->arch |
… | |
… | |
3700 | /* check for hp, sp change */ |
3741 | /* check for hp, sp change */ |
3701 | if (food->stats.hp != 0) |
3742 | if (food->stats.hp != 0) |
3702 | { |
3743 | { |
3703 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3744 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3704 | { |
3745 | { |
3705 | assign (who->contr->killer, food->name); |
3746 | who->contr->killer = food; |
3706 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3747 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3707 | who->failmsg ("Eck!...that was poisonous!"); |
3748 | who->failmsg ("Eck!...that was poisonous!"); |
3708 | } |
3749 | } |
3709 | else |
3750 | else |
3710 | { |
3751 | { |
… | |
… | |
3714 | who->failmsg ("Eck!...that was poisonous!"); |
3755 | who->failmsg ("Eck!...that was poisonous!"); |
3715 | |
3756 | |
3716 | who->stats.hp += food->stats.hp; |
3757 | who->stats.hp += food->stats.hp; |
3717 | } |
3758 | } |
3718 | } |
3759 | } |
|
|
3760 | |
3719 | if (food->stats.sp != 0) |
3761 | if (food->stats.sp != 0) |
3720 | { |
3762 | { |
3721 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3763 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3722 | { |
3764 | { |
3723 | who->failmsg ("You are drained of mana!"); |
3765 | who->failmsg ("You are drained of mana!"); |
… | |
… | |
3909 | if (!strcmp (walk->name, "NOCLASSFACECHANGE")) |
3951 | if (!strcmp (walk->name, "NOCLASSFACECHANGE")) |
3910 | flag_change_face = 0; |
3952 | flag_change_face = 0; |
3911 | |
3953 | |
3912 | if (flag_change_face) |
3954 | if (flag_change_face) |
3913 | { |
3955 | { |
3914 | pl->animation_id = GET_ANIM_ID (change); |
|
|
3915 | pl->face = change->face; |
3956 | pl->face = change->face; |
3916 | |
3957 | pl->animation_id = change->animation_id; |
3917 | if (QUERY_FLAG (change, FLAG_ANIMATE)) |
3958 | pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; |
3918 | SET_FLAG (pl, FLAG_ANIMATE); |
|
|
3919 | else |
|
|
3920 | CLEAR_FLAG (pl, FLAG_ANIMATE); |
|
|
3921 | } |
3959 | } |
3922 | |
3960 | |
3923 | /* check the special case of can't use weapons */ |
3961 | /* check the special case of can't use weapons */ |
3924 | /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ |
3962 | /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ |
3925 | if (!strcmp (change->name, "monk")) |
3963 | if (!strcmp (change->name, "monk")) |