… | |
… | |
139 | if (!item) |
139 | if (!item) |
140 | return 0; |
140 | return 0; |
141 | |
141 | |
142 | for (op = op->below; op; op = op->below) |
142 | for (op = op->below; op; op = op->below) |
143 | if (op->arch->archname == item) |
143 | if (op->arch->archname == item) |
144 | if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED) |
144 | if (!op->flag [FLAG_CURSED] && !op->flag [FLAG_DAMNED] |
145 | && /* Loophole bug? -FD- */ !QUERY_FLAG (op, FLAG_UNPAID)) |
145 | && /* Loophole bug? -FD- */ !op->flag [FLAG_UNPAID]) |
146 | count += op->number_of (); |
146 | count += op->number_of (); |
147 | |
147 | |
148 | return count; |
148 | return count; |
149 | } |
149 | } |
150 | |
150 | |
… | |
… | |
332 | { |
332 | { |
333 | op->failmsg ("This weapon cannot be improved any more."); |
333 | op->failmsg ("This weapon cannot be improved any more."); |
334 | return 0; |
334 | return 0; |
335 | } |
335 | } |
336 | |
336 | |
337 | if (QUERY_FLAG (weapon, FLAG_APPLIED) |
337 | if (weapon->flag [FLAG_APPLIED] |
338 | && !check_item_power (op, weapon->item_power + 1)) |
338 | && !check_item_power (op, weapon->item_power + 1)) |
339 | { |
339 | { |
340 | op->failmsg ("Improving the weapon will make it too " |
340 | op->failmsg ("Improving the weapon will make it too " |
341 | "powerful for you to use. Unready it if you " |
341 | "powerful for you to use. Unready it if you " |
342 | "really want to improve it."); |
342 | "really want to improve it."); |
… | |
… | |
424 | * then calls improve_weapon to do the dirty work. |
424 | * then calls improve_weapon to do the dirty work. |
425 | */ |
425 | */ |
426 | static int |
426 | static int |
427 | check_improve_weapon (object *op, object *tmp) |
427 | check_improve_weapon (object *op, object *tmp) |
428 | { |
428 | { |
429 | object *otmp; |
|
|
430 | |
|
|
431 | if (op->type != PLAYER) |
429 | if (op->type != PLAYER) |
432 | return 0; |
430 | return 0; |
433 | |
431 | |
434 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
432 | if (!op->flag [FLAG_WIZCAST] && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) |
435 | { |
433 | { |
436 | op->failmsg ("Something blocks the magic of the scroll!"); |
434 | op->failmsg ("Something blocks the magic of the scroll!"); |
437 | return 0; |
435 | return 0; |
438 | } |
436 | } |
439 | |
437 | |
440 | otmp = find_marked_object (op); |
438 | object *otmp = op->mark (); |
441 | |
439 | |
442 | if (!otmp) |
440 | if (!otmp) |
443 | { |
441 | { |
444 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
442 | op->failmsg ("You need to mark a weapon object. H<Use the mark command or the mark option from the item popup menu.>"); |
445 | return 0; |
443 | return 0; |
446 | } |
444 | } |
447 | |
445 | |
448 | if (otmp->type != WEAPON && otmp->type != BOW) |
446 | if (otmp->type != WEAPON && otmp->type != BOW) |
449 | { |
447 | { |
450 | op->failmsg ("Marked item is not a weapon or bow!"); |
448 | op->failmsg ("Marked item is not a weapon or bow!"); |
|
|
449 | return 0; |
|
|
450 | } |
|
|
451 | |
|
|
452 | if (!op->apply (otmp, AP_UNAPPLY)) |
|
|
453 | { |
|
|
454 | op->failmsg ("You are unable to take off your weapon to improve it!"); |
451 | return 0; |
455 | return 0; |
452 | } |
456 | } |
453 | |
457 | |
454 | op->statusmsg ("Applied weapon builder."); |
458 | op->statusmsg ("Applied weapon builder."); |
455 | |
459 | |
… | |
… | |
481 | * changing of physical area right now. |
485 | * changing of physical area right now. |
482 | */ |
486 | */ |
483 | static int |
487 | static int |
484 | improve_armour (object *op, object *improver, object *armour) |
488 | improve_armour (object *op, object *improver, object *armour) |
485 | { |
489 | { |
486 | object *tmp; |
|
|
487 | |
|
|
488 | if (armour->magic >= settings.armor_max_enchant) |
490 | if (armour->magic >= settings.armor_max_enchant) |
489 | { |
491 | { |
490 | op->failmsg ("This armour can not be enchanted any further!"); |
492 | op->failmsg ("This armour can not be enchanted any further!"); |
491 | return 0; |
493 | return 0; |
492 | } |
494 | } |
… | |
… | |
503 | } |
505 | } |
504 | |
506 | |
505 | /* Split objects if needed. Can't insert tmp until the |
507 | /* Split objects if needed. Can't insert tmp until the |
506 | * end of this function - otherwise it will just re-merge. |
508 | * end of this function - otherwise it will just re-merge. |
507 | */ |
509 | */ |
508 | tmp = armour->nrof > 1 ? armour->split (armour->nrof - 1) : 0; |
510 | object *tmp = armour->nrof > 1 ? armour->split (armour->nrof - 1) : 0; |
509 | |
511 | |
510 | armour->magic++; |
512 | armour->magic++; |
511 | |
513 | |
512 | if (!settings.armor_speed_linear) |
514 | if (!settings.armor_speed_linear) |
513 | { |
515 | { |
… | |
… | |
551 | |
553 | |
552 | if (op->type == PLAYER) |
554 | if (op->type == PLAYER) |
553 | { |
555 | { |
554 | esrv_send_item (op, armour); |
556 | esrv_send_item (op, armour); |
555 | |
557 | |
556 | if (QUERY_FLAG (armour, FLAG_APPLIED)) |
558 | if (armour->flag [FLAG_APPLIED]) |
557 | op->update_stats (); |
559 | op->update_stats (); |
558 | } |
560 | } |
559 | |
561 | |
560 | improver->decrease (); |
562 | improver->decrease (); |
561 | |
563 | |
… | |
… | |
641 | for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) |
643 | for (ob = converter->inv->below, i = 1; ob; ob = ob->below, i++) |
642 | if (rndm (0, i) == 0) |
644 | if (rndm (0, i) == 0) |
643 | ob_to_copy = ob; |
645 | ob_to_copy = ob; |
644 | |
646 | |
645 | item = ob_to_copy->deep_clone (); |
647 | item = ob_to_copy->deep_clone (); |
646 | CLEAR_FLAG (item, FLAG_IS_A_TEMPLATE); |
648 | item->clr_flag (FLAG_IS_A_TEMPLATE); |
647 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
649 | unflag_inv (item, FLAG_IS_A_TEMPLATE); |
648 | } |
650 | } |
649 | else |
651 | else |
650 | { |
652 | { |
651 | if (!conv_to) |
653 | if (!conv_to) |
… | |
… | |
664 | |
666 | |
665 | if (nr) |
667 | if (nr) |
666 | item->nrof *= nr; |
668 | item->nrof *= nr; |
667 | |
669 | |
668 | if (converter->flag [FLAG_PRECIOUS]) |
670 | if (converter->flag [FLAG_PRECIOUS]) |
669 | SET_FLAG (item, FLAG_UNPAID); |
671 | item->set_flag (FLAG_UNPAID); |
670 | |
672 | |
671 | if (converter->is_in_shop ()) |
673 | if (converter->is_in_shop ()) |
672 | { |
674 | { |
673 | // converters on shop floors don't work anymore, bug lets check for it |
675 | // converters on shop floors don't work anymore, bug lets check for it |
674 | // and report in case someone still does it. |
676 | // and report in case someone still does it. |
675 | LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n", |
677 | LOG (llevDebug, "ITEMBUG: broken converter, converters on shop floor don't work: %s\n", |
676 | converter->debug_desc ()); |
678 | converter->debug_desc ()); |
677 | SET_FLAG (item, FLAG_UNPAID); |
679 | item->set_flag (FLAG_UNPAID); |
678 | } |
680 | } |
679 | else if (price_in < sint64 (item->nrof) * item->value) |
681 | else if (price_in < sint64 (item->nrof) * item->value) |
680 | { |
682 | { |
681 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
683 | LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", |
682 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
684 | &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); |
… | |
… | |
817 | { |
819 | { |
818 | int rv = 0; |
820 | int rv = 0; |
819 | double opinion; |
821 | double opinion; |
820 | object *tmp, *next; |
822 | object *tmp, *next; |
821 | |
823 | |
822 | SET_FLAG (op, FLAG_NO_APPLY); /* prevent loops */ |
824 | op->set_flag (FLAG_NO_APPLY); /* prevent loops */ |
823 | |
825 | |
824 | bool has_unpaid = false; |
826 | bool has_unpaid = false; |
825 | |
827 | |
826 | // quite inefficient to do this here twice, but the api doesn't lend itself to |
828 | // quite inefficient to do this here twice, but the api doesn't lend itself to |
827 | // a quick and small change :( |
829 | // a quick and small change :( |
… | |
… | |
840 | */ |
842 | */ |
841 | for (tmp = op->inv; tmp; tmp = next) |
843 | for (tmp = op->inv; tmp; tmp = next) |
842 | { |
844 | { |
843 | next = tmp->below; |
845 | next = tmp->below; |
844 | |
846 | |
845 | if (QUERY_FLAG (tmp, FLAG_UNPAID)) |
847 | if (tmp->flag [FLAG_UNPAID]) |
846 | { |
848 | { |
847 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
849 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
848 | |
850 | |
849 | if (i >= 0) |
851 | if (i >= 0) |
850 | tmp->move (i); |
852 | tmp->move (i); |
851 | } |
853 | } |
852 | } |
854 | } |
853 | |
855 | |
854 | /* Don't teleport things like spell effects */ |
856 | /* Don't teleport things like spell effects */ |
855 | if (QUERY_FLAG (op, FLAG_NO_PICK)) |
857 | if (op->flag [FLAG_NO_PICK]) |
856 | return 0; |
858 | return 0; |
857 | |
859 | |
858 | /* unpaid objects, or non living objects, can't transfer by |
860 | /* unpaid objects, or non living objects, can't transfer by |
859 | * shop mats. Instead, put it on a nearby space. |
861 | * shop mats. Instead, put it on a nearby space. |
860 | */ |
862 | */ |
861 | if (QUERY_FLAG (op, FLAG_UNPAID) || !QUERY_FLAG (op, FLAG_ALIVE)) |
863 | if (op->flag [FLAG_UNPAID] || !op->flag [FLAG_ALIVE]) |
862 | { |
864 | { |
863 | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
865 | /* Somebody dropped an unpaid item, just move to an adjacent place. */ |
864 | int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
866 | int i = find_free_spot (op, op->map, op->x, op->y, 1, 9); |
865 | |
867 | |
866 | if (i != -1) |
868 | if (i != -1) |
… | |
… | |
921 | op->y += freearr_y[i]; |
923 | op->y += freearr_y[i]; |
922 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
924 | rv = insert_ob_in_map (op, op->map, shop_mat, 0) == NULL; |
923 | } |
925 | } |
924 | } |
926 | } |
925 | |
927 | |
926 | CLEAR_FLAG (op, FLAG_NO_APPLY); |
928 | op->clr_flag (FLAG_NO_APPLY); |
927 | return rv; |
929 | return rv; |
928 | } |
930 | } |
929 | |
931 | |
930 | /** |
932 | /** |
931 | * Handles applying a sign. |
933 | * Handles applying a sign. |
… | |
… | |
959 | op->failmsg ("You cannot read it anymore."); |
961 | op->failmsg ("You cannot read it anymore."); |
960 | |
962 | |
961 | return; |
963 | return; |
962 | } |
964 | } |
963 | |
965 | |
964 | if (!QUERY_FLAG (op, FLAG_WIZPASS)) |
966 | if (!op->flag [FLAG_WIZPASS]) |
965 | sign->last_eat++; |
967 | sign->last_eat++; |
966 | } |
968 | } |
967 | |
969 | |
968 | /* Sign or magic mouth? Do we need to see it, or does it talk to us? |
970 | /* Sign or magic mouth? Do we need to see it, or does it talk to us? |
969 | * No way to know for sure. The presumption is basically that if |
971 | * No way to know for sure. The presumption is basically that if |
970 | * move_on is zero, it needs to be manually applied (doesn't talk |
972 | * move_on is zero, it needs to be manually applied (doesn't talk |
971 | * to us). |
973 | * to us). |
972 | */ |
974 | */ |
973 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) |
975 | if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ] && !sign->move_on) |
974 | { |
976 | { |
975 | op->failmsg ("You are unable to read while blind!"); |
977 | op->failmsg ("You are unable to read while blind!"); |
976 | return; |
978 | return; |
977 | } |
979 | } |
978 | |
980 | |
… | |
… | |
1165 | static bool |
1167 | static bool |
1166 | unapply_for_ob (object *who, object *op, int aflags) |
1168 | unapply_for_ob (object *who, object *op, int aflags) |
1167 | { |
1169 | { |
1168 | if (op->is_range ()) |
1170 | if (op->is_range ()) |
1169 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
1171 | for (object *tmp = who->inv; tmp; tmp = tmp->below) |
1170 | if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) |
1172 | if (tmp->flag [FLAG_APPLIED] && tmp->is_range ()) |
1171 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED))) |
1173 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!tmp->flag [FLAG_CURSED] && !tmp->flag [FLAG_DAMNED])) |
1172 | { |
1174 | { |
1173 | if (aflags & AP_PRINT) |
1175 | if (aflags & AP_PRINT) |
1174 | who->failmsg (query_name (tmp)); |
1176 | who->failmsg (query_name (tmp)); |
1175 | else |
1177 | else |
1176 | unapply_special (who, tmp, aflags); |
1178 | unapply_special (who, tmp, aflags); |
… | |
… | |
1209 | #endif |
1211 | #endif |
1210 | return 1; |
1212 | return 1; |
1211 | } |
1213 | } |
1212 | |
1214 | |
1213 | /* If we are just printing, we don't care about cursed status */ |
1215 | /* If we are just printing, we don't care about cursed status */ |
1214 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)))) |
1216 | if ((aflags & AP_IGNORE_CURSE) || (aflags & AP_PRINT) || (!(tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]))) |
1215 | { |
1217 | { |
1216 | if (aflags & AP_PRINT) |
1218 | if (aflags & AP_PRINT) |
1217 | who->failmsg (query_name (tmp)); |
1219 | who->failmsg (query_name (tmp)); |
1218 | else |
1220 | else |
1219 | unapply_special (who, tmp, aflags); |
1221 | unapply_special (who, tmp, aflags); |
… | |
… | |
1331 | * the weapon/shield checks, and the range checks for monsters, |
1333 | * the weapon/shield checks, and the range checks for monsters, |
1332 | * because you can't control those just by body location - bows, shields, |
1334 | * because you can't control those just by body location - bows, shields, |
1333 | * and weapons all use the same slot. Similar for horn/rod/wand - they |
1335 | * and weapons all use the same slot. Similar for horn/rod/wand - they |
1334 | * all use the same location. |
1336 | * all use the same location. |
1335 | */ |
1337 | */ |
1336 | if (op->type == WEAPON && !QUERY_FLAG (who, FLAG_USE_WEAPON)) |
1338 | if (op->type == WEAPON && !who->flag [FLAG_USE_WEAPON]) |
1337 | retval |= CAN_APPLY_RESTRICTION; |
1339 | retval |= CAN_APPLY_RESTRICTION; |
1338 | |
1340 | |
1339 | if (op->type == SHIELD && !QUERY_FLAG (who, FLAG_USE_SHIELD)) |
1341 | if (op->type == SHIELD && !who->flag [FLAG_USE_SHIELD]) |
1340 | retval |= CAN_APPLY_RESTRICTION; |
1342 | retval |= CAN_APPLY_RESTRICTION; |
1341 | |
1343 | |
1342 | if (who->type != PLAYER) |
1344 | if (who->type != PLAYER) |
1343 | { |
1345 | { |
1344 | if ((op->type == WAND || op->type == HORN || op->type == ROD) && !QUERY_FLAG (who, FLAG_USE_RANGE)) |
1346 | if ((op->type == WAND || op->type == HORN || op->type == ROD) && !who->flag [FLAG_USE_RANGE]) |
1345 | retval |= CAN_APPLY_RESTRICTION; |
1347 | retval |= CAN_APPLY_RESTRICTION; |
1346 | |
1348 | |
1347 | if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) |
1349 | if (op->type == BOW && !who->flag [FLAG_USE_BOW]) |
1348 | retval |= CAN_APPLY_RESTRICTION; |
1350 | retval |= CAN_APPLY_RESTRICTION; |
1349 | |
1351 | |
1350 | if (op->type == RING && !QUERY_FLAG (who, FLAG_USE_RING)) |
1352 | if (op->type == RING && !who->flag [FLAG_USE_RING]) |
1351 | retval |= CAN_APPLY_RESTRICTION; |
1353 | retval |= CAN_APPLY_RESTRICTION; |
1352 | |
1354 | |
1353 | if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) |
1355 | if (op->type == BOW && !who->flag [FLAG_USE_BOW]) |
1354 | retval |= CAN_APPLY_RESTRICTION; |
1356 | retval |= CAN_APPLY_RESTRICTION; |
1355 | } |
1357 | } |
1356 | |
1358 | |
1357 | return retval; |
1359 | return retval; |
1358 | } |
1360 | } |
… | |
… | |
1399 | //TODO: remove these when apply_special is no longer exposed |
1401 | //TODO: remove these when apply_special is no longer exposed |
1400 | if (op->env != who) |
1402 | if (op->env != who) |
1401 | return 1; /* op is not in inventory */ |
1403 | return 1; /* op is not in inventory */ |
1402 | |
1404 | |
1403 | /* trying to unequip op */ |
1405 | /* trying to unequip op */ |
1404 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1406 | if (op->flag [FLAG_APPLIED]) |
1405 | { |
1407 | { |
1406 | /* always apply, so no reason to unapply */ |
1408 | /* always apply, so no reason to unapply */ |
1407 | if (basic_flag == AP_APPLY) |
1409 | if (basic_flag == AP_APPLY) |
1408 | return 0; |
1410 | return 0; |
1409 | |
1411 | |
1410 | if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) |
1412 | if (!(aflags & AP_IGNORE_CURSE) && (op->flag [FLAG_CURSED] || op->flag [FLAG_DAMNED])) |
1411 | { |
1413 | { |
1412 | who->failmsgf ("No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, query_name (op)); |
1414 | who->failmsgf ("No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED, query_name (op)); |
1413 | return 1; |
1415 | return 1; |
1414 | } |
1416 | } |
1415 | |
1417 | |
… | |
… | |
1524 | case GIRDLE: |
1526 | case GIRDLE: |
1525 | case BRACERS: |
1527 | case BRACERS: |
1526 | case CLOAK: |
1528 | case CLOAK: |
1527 | case RING: |
1529 | case RING: |
1528 | case AMULET: |
1530 | case AMULET: |
1529 | SET_FLAG (op, FLAG_APPLIED); |
1531 | op->set_flag (FLAG_APPLIED); |
1530 | who->statusmsg (format ("You wear %s.", query_name (op))); |
1532 | who->statusmsg (format ("You wear %s.", query_name (op))); |
1531 | change_abil (who, op); |
1533 | change_abil (who, op); |
1532 | break; |
1534 | break; |
1533 | |
1535 | |
1534 | case SKILL_TOOL: |
1536 | case SKILL_TOOL: |
1535 | // applying a skill tool does not ready the skill |
1537 | // applying a skill tool does not ready the skill |
1536 | // if something needs the skill, it has to ready it itself |
1538 | // if something needs the skill, it has to ready it itself |
1537 | //TODO: unapplying should unapply the skill, though |
1539 | //TODO: unapplying should unapply the skill, though |
1538 | SET_FLAG (op, FLAG_APPLIED); |
1540 | op->set_flag (FLAG_APPLIED); |
1539 | break; |
1541 | break; |
1540 | |
1542 | |
1541 | case SKILL: |
1543 | case SKILL: |
1542 | if (!(aflags & AP_NO_SLOT)) |
1544 | if (!(aflags & AP_NO_SLOT)) |
1543 | { |
1545 | { |
… | |
… | |
1581 | who->statusmsg (format ("You can now use the %s skill.", &op->skill)); |
1583 | who->statusmsg (format ("You can now use the %s skill.", &op->skill)); |
1582 | else |
1584 | else |
1583 | who->statusmsg (format ("You ready %s.", query_name (op))); |
1585 | who->statusmsg (format ("You ready %s.", query_name (op))); |
1584 | } |
1586 | } |
1585 | |
1587 | |
1586 | SET_FLAG (who, FLAG_READY_SKILL); |
1588 | who->set_flag (FLAG_READY_SKILL); |
1587 | SET_FLAG (op, FLAG_APPLIED); |
1589 | op->set_flag (FLAG_APPLIED); |
1588 | change_abil (who, op); |
1590 | change_abil (who, op); |
1589 | break; |
1591 | break; |
1590 | |
1592 | |
1591 | case BOW: |
1593 | case BOW: |
1592 | if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\'')) |
1594 | if (op->level && (!op->name.starts_with (who->name) || op->name [who->name.length ()] != '\'')) |
… | |
… | |
1656 | |
1658 | |
1657 | default: |
1659 | default: |
1658 | who->statusmsg (format ("You apply %s.", query_name (op))); |
1660 | who->statusmsg (format ("You apply %s.", query_name (op))); |
1659 | } |
1661 | } |
1660 | |
1662 | |
1661 | SET_FLAG (op, FLAG_APPLIED); |
1663 | op->set_flag (FLAG_APPLIED); |
1662 | |
1664 | |
1663 | if (tmp) who->insert (tmp); |
1665 | if (tmp) who->insert (tmp); |
1664 | |
1666 | |
1665 | who->update_stats (); |
1667 | who->update_stats (); |
1666 | |
1668 | |
1667 | /* We exclude spell casting objects. The fire code will set the |
1669 | /* We exclude spell casting objects. The fire code will set the |
1668 | * been applied flag when they are used - until that point, |
1670 | * been applied flag when they are used - until that point, |
1669 | * you don't know anything about them. |
1671 | * you don't know anything about them. |
1670 | */ |
1672 | */ |
1671 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
1673 | if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) |
1672 | SET_FLAG (op, FLAG_BEEN_APPLIED); |
1674 | op->set_flag (FLAG_BEEN_APPLIED); |
1673 | |
1675 | |
1674 | if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) |
1676 | if (op->flag [FLAG_CURSED] || op->flag [FLAG_DAMNED]) |
1675 | if (who->type == PLAYER) |
1677 | if (who->type == PLAYER) |
1676 | { |
1678 | { |
1677 | who->failmsg ( |
1679 | who->failmsg ( |
1678 | "Oops, it feels deadly cold! " |
1680 | "Oops, it feels deadly cold! " |
1679 | "H<Maybe it wasn't such a bright idea to apply this cursed or damned item.>" |
1681 | "H<Maybe it wasn't such a bright idea to apply this cursed or damned item.>" |
1680 | ); |
1682 | ); |
1681 | SET_FLAG (op, FLAG_KNOWN_CURSED); |
1683 | op->set_flag (FLAG_KNOWN_CURSED); |
1682 | } |
1684 | } |
1683 | |
1685 | |
1684 | if (object *pl = op->visible_to ()) |
1686 | if (object *pl = op->visible_to ()) |
1685 | esrv_send_item (pl, op); |
1687 | esrv_send_item (pl, op); |
1686 | |
1688 | |
… | |
… | |
1759 | return 0; |
1761 | return 0; |
1760 | |
1762 | |
1761 | /* if the player has a marked item, identify that if it needs to be |
1763 | /* if the player has a marked item, identify that if it needs to be |
1762 | * identified. If it doesn't, then go through the player inventory. |
1764 | * identified. If it doesn't, then go through the player inventory. |
1763 | */ |
1765 | */ |
1764 | if (object *marked = find_marked_object (pl)) |
1766 | if (object *marked = pl->mark ()) |
1765 | if (!QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked)) |
1767 | if (!marked->flag [FLAG_IDENTIFIED] && need_identify (marked)) |
1766 | { |
1768 | { |
1767 | if (operate_altar (altar, &money, pl)) |
1769 | if (operate_altar (altar, &money, pl)) |
1768 | { |
1770 | { |
1769 | identify (marked); |
1771 | identify (marked); |
1770 | |
1772 | |
… | |
… | |
1776 | } |
1778 | } |
1777 | } |
1779 | } |
1778 | |
1780 | |
1779 | for (object *id = pl->inv; id; id = id->below) |
1781 | for (object *id = pl->inv; id; id = id->below) |
1780 | { |
1782 | { |
1781 | if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) |
1783 | if (!id->flag [FLAG_IDENTIFIED] && !id->invisible && need_identify (id)) |
1782 | { |
1784 | { |
1783 | if (operate_altar (altar, &money, pl)) |
1785 | if (operate_altar (altar, &money, pl)) |
1784 | { |
1786 | { |
1785 | identify (id); |
1787 | identify (id); |
1786 | |
1788 | |
… | |
… | |
1832 | |
1834 | |
1833 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1835 | if (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_SAFE) |
1834 | { |
1836 | { |
1835 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
1837 | op->failmsg ("Gods prevent you from using this here, it's sacred ground!"); |
1836 | |
1838 | |
1837 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
1839 | tmp->clr_flag (FLAG_APPLIED); |
1838 | return 0; |
1840 | return 0; |
1839 | } |
1841 | } |
1840 | |
1842 | |
1841 | if (op->type == PLAYER) |
1843 | if (op->type == PLAYER) |
1842 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
1844 | if (!tmp->flag [FLAG_IDENTIFIED]) |
1843 | identify (tmp); |
1845 | identify (tmp); |
1844 | |
1846 | |
1845 | handle_apply_yield (tmp); |
1847 | handle_apply_yield (tmp); |
1846 | |
1848 | |
1847 | /* Potion of restoration - only for players */ |
1849 | /* Potion of restoration - only for players */ |
1848 | if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) |
1850 | if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) |
1849 | { |
1851 | { |
1850 | object *depl; |
1852 | object *depl; |
1851 | archetype *at; |
1853 | archetype *at; |
1852 | |
1854 | |
1853 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
1855 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
1854 | { |
1856 | { |
1855 | op->drain_stat (); |
1857 | op->drain_stat (); |
1856 | op->update_stats (); |
1858 | op->update_stats (); |
1857 | tmp->decrease (); |
1859 | tmp->decrease (); |
1858 | return 1; |
1860 | return 1; |
… | |
… | |
1885 | /* improvement potion - only for players */ |
1887 | /* improvement potion - only for players */ |
1886 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
1888 | if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) |
1887 | { |
1889 | { |
1888 | for (i = 1; i < min (11, op->level); i++) |
1890 | for (i = 1; i < min (11, op->level); i++) |
1889 | { |
1891 | { |
1890 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
1892 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
1891 | { |
1893 | { |
1892 | if (op->contr->levhp[i] != 1) |
1894 | if (op->contr->levhp[i] != 1) |
1893 | { |
1895 | { |
1894 | op->contr->levhp[i] = 1; |
1896 | op->contr->levhp[i] = 1; |
1895 | break; |
1897 | break; |
… | |
… | |
1931 | |
1933 | |
1932 | /* Just makes checking easier */ |
1934 | /* Just makes checking easier */ |
1933 | if (i < min (11, op->level)) |
1935 | if (i < min (11, op->level)) |
1934 | got_one = 1; |
1936 | got_one = 1; |
1935 | |
1937 | |
1936 | if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) |
1938 | if (!tmp->flag [FLAG_CURSED] && !tmp->flag [FLAG_DAMNED]) |
1937 | { |
1939 | { |
1938 | if (got_one) |
1940 | if (got_one) |
1939 | { |
1941 | { |
1940 | op->update_stats (); |
1942 | op->update_stats (); |
1941 | op->statusmsg ("The Gods smile upon you and remake you " |
1943 | op->statusmsg ("The Gods smile upon you and remake you " |
… | |
… | |
1966 | * there is no limit to the number of spells that potions can be cast, |
1968 | * there is no limit to the number of spells that potions can be cast, |
1967 | * but direction is problematic to try and imbue fireball potions for example. |
1969 | * but direction is problematic to try and imbue fireball potions for example. |
1968 | */ |
1970 | */ |
1969 | if (tmp->inv) |
1971 | if (tmp->inv) |
1970 | { |
1972 | { |
1971 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
1973 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
1972 | { |
1974 | { |
1973 | op->failmsg ("Yech! Your lungs are on fire!"); |
1975 | op->failmsg ("Yech! Your lungs are on fire!"); |
1974 | create_exploding_ball_at (op, op->level); |
1976 | create_exploding_ball_at (op, op->level); |
1975 | } |
1977 | } |
1976 | else |
1978 | else |
1977 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
1979 | cast_spell (op, tmp, op->facing, tmp->inv, NULL); |
1978 | |
1980 | |
1979 | tmp->decrease (); |
1981 | tmp->decrease (); |
1980 | |
1982 | |
1981 | /* if youre dead, no point in doing this... */ |
1983 | /* if youre dead, no point in doing this... */ |
1982 | if (!QUERY_FLAG (op, FLAG_REMOVED)) |
1984 | if (!op->flag [FLAG_REMOVED]) |
1983 | op->update_stats (); |
1985 | op->update_stats (); |
1984 | |
1986 | |
1985 | return 1; |
1987 | return 1; |
1986 | } |
1988 | } |
1987 | |
1989 | |
… | |
… | |
2002 | |
2004 | |
2003 | /* This is a protection potion */ |
2005 | /* This is a protection potion */ |
2004 | if (force) |
2006 | if (force) |
2005 | { |
2007 | { |
2006 | /* cursed items last longer */ |
2008 | /* cursed items last longer */ |
2007 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
2009 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
2008 | { |
2010 | { |
2009 | force->stats.food *= 10; |
2011 | force->stats.food *= 10; |
2010 | for (i = 0; i < NROFATTACKS; i++) |
2012 | for (i = 0; i < NROFATTACKS; i++) |
2011 | if (force->resist[i] > 0) |
2013 | if (force->resist[i] > 0) |
2012 | force->resist[i] = -force->resist[i]; /* prot => vuln */ |
2014 | force->resist[i] = -force->resist[i]; /* prot => vuln */ |
2013 | } |
2015 | } |
2014 | |
2016 | |
2015 | force->speed_left = -1; |
2017 | force->speed_left = -1; |
2016 | force = insert_ob_in_ob (force, op); |
2018 | force = insert_ob_in_ob (force, op); |
2017 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
2019 | tmp->clr_flag (FLAG_APPLIED); |
2018 | SET_FLAG (force, FLAG_APPLIED); |
2020 | force->set_flag (FLAG_APPLIED); |
2019 | change_abil (op, force); |
2021 | change_abil (op, force); |
2020 | tmp->decrease (); |
2022 | tmp->decrease (); |
2021 | return 1; |
2023 | return 1; |
2022 | } |
2024 | } |
2023 | |
2025 | |
2024 | /* Only thing left are the stat potions */ |
2026 | /* Only thing left are the stat potions */ |
2025 | if (op->type == PLAYER) |
2027 | if (op->type == PLAYER) |
2026 | { /* only for players */ |
2028 | { /* only for players */ |
2027 | if ((QUERY_FLAG (tmp, FLAG_CURSED) |
2029 | if ((tmp->flag [FLAG_CURSED] |
2028 | || QUERY_FLAG (tmp, FLAG_DAMNED)) |
2030 | || tmp->flag [FLAG_DAMNED]) |
2029 | && tmp->value != 0) |
2031 | && tmp->value != 0) |
2030 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
2032 | tmp->clr_flag (FLAG_APPLIED); |
2031 | else |
2033 | else |
2032 | SET_FLAG (tmp, FLAG_APPLIED); |
2034 | tmp->set_flag (FLAG_APPLIED); |
2033 | |
2035 | |
2034 | if (!change_abil (op, tmp)) |
2036 | if (!change_abil (op, tmp)) |
2035 | op->statusmsg ("Nothing happened."); |
2037 | op->statusmsg ("Nothing happened."); |
2036 | } |
2038 | } |
2037 | |
2039 | |
2038 | /* CLEAR_FLAG is so that if the character has other potions |
2040 | /* CLEAR_FLAG is so that if the character has other potions |
2039 | * that were grouped with the one consumed, his |
2041 | * that were grouped with the one consumed, his |
2040 | * stat will not be raised by them. fix_player just clears |
2042 | * stat will not be raised by them. fix_player just clears |
2041 | * up all the stats. |
2043 | * up all the stats. |
2042 | */ |
2044 | */ |
2043 | CLEAR_FLAG (tmp, FLAG_APPLIED); |
2045 | tmp->clr_flag (FLAG_APPLIED); |
2044 | op->update_stats (); |
2046 | op->update_stats (); |
2045 | tmp->decrease (); |
2047 | tmp->decrease (); |
2046 | return 1; |
2048 | return 1; |
2047 | } |
2049 | } |
2048 | |
2050 | |
… | |
… | |
2059 | move_apply (object *trap, object *victim, object *originator) |
2061 | move_apply (object *trap, object *victim, object *originator) |
2060 | { |
2062 | { |
2061 | static int recursion_depth = 0; |
2063 | static int recursion_depth = 0; |
2062 | |
2064 | |
2063 | /* Only exits affect DMs. */ |
2065 | /* Only exits affect DMs. */ |
2064 | if (QUERY_FLAG (victim, FLAG_WIZPASS) && trap->type != EXIT && trap->type != SIGN) |
2066 | if (victim->flag [FLAG_WIZPASS] && trap->type != EXIT && trap->type != SIGN) |
2065 | return; |
2067 | return; |
2066 | |
2068 | |
2067 | /* move_apply() is the most likely candidate for causing unwanted and |
2069 | /* move_apply() is the most likely candidate for causing unwanted and |
2068 | * possibly unlimited recursion. |
2070 | * possibly unlimited recursion. |
2069 | */ |
2071 | */ |
… | |
… | |
2145 | * trigger this here and get hit by own missile - and will be own enemy. |
2147 | * trigger this here and get hit by own missile - and will be own enemy. |
2146 | * Victim then is his own enemy and will start to kill herself (this is |
2148 | * Victim then is his own enemy and will start to kill herself (this is |
2147 | * removed) but we have not synced victim and his missile. To avoid senseless |
2149 | * removed) but we have not synced victim and his missile. To avoid senseless |
2148 | * action, we avoid hits here |
2150 | * action, we avoid hits here |
2149 | */ |
2151 | */ |
2150 | if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->has_active_speed ()) |
2152 | if ((victim->flag [FLAG_ALIVE] && trap->has_active_speed ()) |
2151 | && trap->owner != victim) |
2153 | && trap->owner != victim) |
2152 | hit_with_arrow (trap, victim); |
2154 | hit_with_arrow (trap, victim); |
2153 | break; |
2155 | break; |
2154 | |
2156 | |
2155 | case SPELL_EFFECT: |
2157 | case SPELL_EFFECT: |
… | |
… | |
2263 | apply_container (victim, trap); |
2265 | apply_container (victim, trap); |
2264 | break; |
2266 | break; |
2265 | |
2267 | |
2266 | case RUNE: |
2268 | case RUNE: |
2267 | case TRAP: |
2269 | case TRAP: |
2268 | if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) |
2270 | if (trap->level && victim->flag [FLAG_ALIVE]) |
2269 | spring_trap (trap, victim); |
2271 | spring_trap (trap, victim); |
2270 | break; |
2272 | break; |
2271 | |
2273 | |
2272 | default: |
2274 | default: |
2273 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
2275 | LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " |
… | |
… | |
2285 | apply_book (object *op, object *tmp) |
2287 | apply_book (object *op, object *tmp) |
2286 | { |
2288 | { |
2287 | int lev_diff; |
2289 | int lev_diff; |
2288 | object *skill_ob; |
2290 | object *skill_ob; |
2289 | |
2291 | |
2290 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
2292 | if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ]) |
2291 | { |
2293 | { |
2292 | op->failmsg ("You are unable to read while blind!"); |
2294 | op->failmsg ("You are unable to read while blind!"); |
2293 | return; |
2295 | return; |
2294 | } |
2296 | } |
2295 | |
2297 | |
… | |
… | |
2306 | op->failmsgf ("You are unable to decipher the strange symbols. H<You lack the %s skill to read this.>", &tmp->skill); |
2308 | op->failmsgf ("You are unable to decipher the strange symbols. H<You lack the %s skill to read this.>", &tmp->skill); |
2307 | return; |
2309 | return; |
2308 | } |
2310 | } |
2309 | |
2311 | |
2310 | lev_diff = tmp->level - (skill_ob->level + 5); |
2312 | lev_diff = tmp->level - (skill_ob->level + 5); |
2311 | if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) |
2313 | if (!op->flag [FLAG_WIZ] && lev_diff > 0) |
2312 | { |
2314 | { |
2313 | op->failmsg (lev_diff < 2 ? "This book is just barely beyond your comprehension." |
2315 | op->failmsg (lev_diff < 2 ? "This book is just barely beyond your comprehension." |
2314 | : lev_diff < 3 ? "This book is slightly beyond your comprehension." |
2316 | : lev_diff < 3 ? "This book is slightly beyond your comprehension." |
2315 | : lev_diff < 5 ? "This book is beyond your comprehension." |
2317 | : lev_diff < 5 ? "This book is beyond your comprehension." |
2316 | : lev_diff < 8 ? "This book is quite a bit beyond your comprehension." |
2318 | : lev_diff < 8 ? "This book is quite a bit beyond your comprehension." |
… | |
… | |
2327 | if (player *pl = op->contr) |
2329 | if (player *pl = op->contr) |
2328 | if (client *ns = pl->ns) |
2330 | if (client *ns = pl->ns) |
2329 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
2331 | pl->infobox (MSG_CHANNEL ("book"), format ("T<%s>\n\n%s", (char *)long_desc (tmp, op), &tmp->msg)); |
2330 | |
2332 | |
2331 | /* gain xp from reading */ |
2333 | /* gain xp from reading */ |
2332 | if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT)) |
2334 | if (!tmp->flag [FLAG_NO_SKILL_IDENT]) |
2333 | { /* only if not read before */ |
2335 | { /* only if not read before */ |
2334 | int exp_gain = calc_skill_exp (op, tmp, skill_ob); |
2336 | int exp_gain = calc_skill_exp (op, tmp, skill_ob); |
2335 | |
2337 | |
2336 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
2338 | if (!tmp->flag [FLAG_IDENTIFIED]) |
2337 | { |
2339 | { |
2338 | /*exp_gain *= 2; because they just identified it too */ |
2340 | /*exp_gain *= 2; because they just identified it too */ |
2339 | SET_FLAG (tmp, FLAG_IDENTIFIED); |
2341 | tmp->set_flag (FLAG_IDENTIFIED); |
2340 | |
2342 | |
2341 | if (object *pl = tmp->visible_to ()) |
2343 | if (object *pl = tmp->visible_to ()) |
2342 | esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp); |
2344 | esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp); |
2343 | } |
2345 | } |
2344 | |
2346 | |
2345 | change_exp (op, exp_gain, skill_ob->skill, 0); |
2347 | change_exp (op, exp_gain, skill_ob->skill, 0); |
2346 | SET_FLAG (tmp, FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
2348 | tmp->set_flag (FLAG_NO_SKILL_IDENT); /* so no more xp gained from this book */ |
2347 | } |
2349 | } |
2348 | } |
2350 | } |
2349 | |
2351 | |
2350 | /** |
2352 | /** |
2351 | * op made some mistake with a scroll, this takes care of punishment. |
2353 | * op made some mistake with a scroll, this takes care of punishment. |
… | |
… | |
2444 | } |
2446 | } |
2445 | |
2447 | |
2446 | /* Upgrade special prayers to normal prayers */ |
2448 | /* Upgrade special prayers to normal prayers */ |
2447 | if ((tmp = check_spell_known (op, spell->name)) != NULL) |
2449 | if ((tmp = check_spell_known (op, spell->name)) != NULL) |
2448 | { |
2450 | { |
2449 | if (special_prayer && !QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
2451 | if (special_prayer && !tmp->flag [FLAG_STARTEQUIP]) |
2450 | { |
2452 | { |
2451 | LOG (llevError, "BUG: do_learn_spell(): spell already known, but not marked as startequip\n"); |
2453 | LOG (llevError, "BUG: do_learn_spell(): spell already known, but not marked as startequip\n"); |
2452 | return; |
2454 | return; |
2453 | } |
2455 | } |
2454 | return; |
2456 | return; |
… | |
… | |
2458 | |
2460 | |
2459 | tmp = spell->clone (); |
2461 | tmp = spell->clone (); |
2460 | insert_ob_in_ob (tmp, op); |
2462 | insert_ob_in_ob (tmp, op); |
2461 | |
2463 | |
2462 | if (special_prayer) |
2464 | if (special_prayer) |
2463 | SET_FLAG (tmp, FLAG_STARTEQUIP); |
2465 | tmp->set_flag (FLAG_STARTEQUIP); |
2464 | |
2466 | |
2465 | esrv_add_spells (op->contr, tmp); |
2467 | esrv_add_spells (op->contr, tmp); |
2466 | } |
2468 | } |
2467 | |
2469 | |
2468 | /** |
2470 | /** |
… | |
… | |
2497 | static void |
2499 | static void |
2498 | apply_spellbook (object *op, object *tmp) |
2500 | apply_spellbook (object *op, object *tmp) |
2499 | { |
2501 | { |
2500 | object *skop, *spell, *spell_skill; |
2502 | object *skop, *spell, *spell_skill; |
2501 | |
2503 | |
2502 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
2504 | if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ]) |
2503 | { |
2505 | { |
2504 | op->failmsg ("You are unable to read while blind."); |
2506 | op->failmsg ("You are unable to read while blind."); |
2505 | return; |
2507 | return; |
2506 | } |
2508 | } |
2507 | |
2509 | |
… | |
… | |
2551 | return; |
2553 | return; |
2552 | } |
2554 | } |
2553 | |
2555 | |
2554 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", ordinal (spell->level), &spell->name)); |
2556 | op->statusmsg (format ("The spellbook contains the %s level spell %s.", ordinal (spell->level), &spell->name)); |
2555 | |
2557 | |
2556 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
2558 | if (!tmp->flag [FLAG_IDENTIFIED]) |
2557 | identify (tmp); |
2559 | identify (tmp); |
2558 | |
2560 | |
2559 | /* I removed the check for special_prayer_mark here - it didn't make |
2561 | /* I removed the check for special_prayer_mark here - it didn't make |
2560 | * a lot of sense - special prayers are not found in spellbooks, and |
2562 | * a lot of sense - special prayers are not found in spellbooks, and |
2561 | * if the player doesn't know the spell, doesn't make a lot of sense that |
2563 | * if the player doesn't know the spell, doesn't make a lot of sense that |
… | |
… | |
2594 | * 3 -Automatically fail to learn if you read while confused |
2596 | * 3 -Automatically fail to learn if you read while confused |
2595 | * |
2597 | * |
2596 | * Overall, chances are the same but a player will find having a high |
2598 | * Overall, chances are the same but a player will find having a high |
2597 | * literacy rate very useful! -b.t. |
2599 | * literacy rate very useful! -b.t. |
2598 | */ |
2600 | */ |
2599 | if (QUERY_FLAG (op, FLAG_CONFUSED)) |
2601 | if (op->flag [FLAG_CONFUSED]) |
2600 | { |
2602 | { |
2601 | op->failmsg ("In your confused state you flub the wording of the text!"); |
2603 | op->failmsg ("In your confused state you flub the wording of the text!"); |
2602 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), max (spell->stats.sp, spell->stats.grace)); |
2604 | scroll_failure (op, 0 - random_roll (0, spell->level, op, PREFER_LOW), max (spell->stats.sp, spell->stats.grace)); |
2603 | } |
2605 | } |
2604 | else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || |
2606 | else if (tmp->flag [FLAG_STARTEQUIP] || |
2605 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
2607 | (random_roll (0, 100, op, PREFER_LOW) - (5 * skop->level)) < learn_spell[spell->stats.grace ? op->stats.Wis : op->stats.Int]) |
2606 | { |
2608 | { |
2607 | op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); |
2609 | op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); |
2608 | do_learn_spell (op, spell, 0); |
2610 | do_learn_spell (op, spell, 0); |
2609 | |
2611 | |
2610 | /* xp gain to literacy for spell learning */ |
2612 | /* xp gain to literacy for spell learning */ |
2611 | if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) |
2613 | if (!tmp->flag [FLAG_STARTEQUIP]) |
2612 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
2614 | change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); |
2613 | } |
2615 | } |
2614 | else |
2616 | else |
2615 | { |
2617 | { |
2616 | op->contr->play_sound (sound_find ("fumble_spell")); |
2618 | op->contr->play_sound (sound_find ("fumble_spell")); |
… | |
… | |
2626 | void |
2628 | void |
2627 | apply_scroll (object *op, object *tmp, int dir) |
2629 | apply_scroll (object *op, object *tmp, int dir) |
2628 | { |
2630 | { |
2629 | object *skop; |
2631 | object *skop; |
2630 | |
2632 | |
2631 | if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) |
2633 | if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ]) |
2632 | { |
2634 | { |
2633 | op->failmsg ("You are unable to read while blind."); |
2635 | op->failmsg ("You are unable to read while blind."); |
2634 | return; |
2636 | return; |
2635 | } |
2637 | } |
2636 | |
2638 | |
… | |
… | |
2646 | int exp_gain = 0; |
2648 | int exp_gain = 0; |
2647 | |
2649 | |
2648 | /* hard code literacy - tmp->skill points to where the exp |
2650 | /* hard code literacy - tmp->skill points to where the exp |
2649 | * should go for anything killed by the spell. |
2651 | * should go for anything killed by the spell. |
2650 | */ |
2652 | */ |
2651 | skop = find_skill_by_name (op, skill_names[SK_LITERACY]); |
2653 | skop = find_skill_by_name (op, shstr_literacy); |
2652 | |
2654 | |
2653 | if (!skop) |
2655 | if (!skop) |
2654 | { |
2656 | { |
2655 | op->failmsgf ("You are unable to decipher the strange symbols. H<You lack the %s skill.>", &skill_names[SK_LITERACY]); |
2657 | op->failmsgf ("You are unable to decipher the strange symbols. H<You lack the literacy skill.>"); |
2656 | return; |
2658 | return; |
2657 | } |
2659 | } |
2658 | |
2660 | |
2659 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
2661 | if ((exp_gain = calc_skill_exp (op, tmp, skop))) |
2660 | change_exp (op, exp_gain, skop->skill, 0); |
2662 | change_exp (op, exp_gain, skop->skill, 0); |
2661 | } |
2663 | } |
2662 | |
2664 | |
2663 | if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) |
2665 | if (!tmp->flag [FLAG_IDENTIFIED]) |
2664 | identify (tmp); |
2666 | identify (tmp); |
2665 | |
2667 | |
2666 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
2668 | op->statusmsg (format ("The scroll of %s turns to dust.", &tmp->inv->name)); |
2667 | |
2669 | |
2668 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
2670 | cast_spell (op, tmp, dir, tmp->inv, NULL); |
… | |
… | |
2699 | |
2701 | |
2700 | treas->x = op->x; |
2702 | treas->x = op->x; |
2701 | treas->y = op->y; |
2703 | treas->y = op->y; |
2702 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2704 | treas = insert_ob_in_map (treas, op->map, op, INS_BELOW_ORIGINATOR); |
2703 | |
2705 | |
2704 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && QUERY_FLAG (op, FLAG_ALIVE)) |
2706 | if (treas && (treas->type == RUNE || treas->type == TRAP) && treas->level && op->flag [FLAG_ALIVE]) |
2705 | spring_trap (treas, op); |
2707 | spring_trap (treas, op); |
2706 | |
2708 | |
2707 | /* If either player or container was destroyed, no need to do |
2709 | /* If either player or container was destroyed, no need to do |
2708 | * further processing. I think this should be enclused with |
2710 | * further processing. I think this should be enclused with |
2709 | * spring trap above, as I don't think there is otherwise |
2711 | * spring trap above, as I don't think there is otherwise |
… | |
… | |
2908 | : tmp->type == DRINK |
2910 | : tmp->type == DRINK |
2909 | ? sound_find ("eat_drink") |
2911 | ? sound_find ("eat_drink") |
2910 | : sound_find ("eat_food") |
2912 | : sound_find ("eat_food") |
2911 | ); |
2913 | ); |
2912 | |
2914 | |
2913 | if (!QUERY_FLAG (tmp, FLAG_CURSED)) |
2915 | if (!tmp->flag [FLAG_CURSED]) |
2914 | { |
2916 | { |
2915 | const char *buf; |
2917 | const char *buf; |
2916 | |
2918 | |
2917 | if (!op->is_dragon ()) |
2919 | if (!op->is_dragon ()) |
2918 | { |
2920 | { |
… | |
… | |
2938 | min_it (op->stats.hp, op->stats.maxhp); |
2940 | min_it (op->stats.hp, op->stats.maxhp); |
2939 | min_it (op->stats.food, MAX_FOOD); |
2941 | min_it (op->stats.food, MAX_FOOD); |
2940 | } |
2942 | } |
2941 | |
2943 | |
2942 | /* special food hack -b.t. */ |
2944 | /* special food hack -b.t. */ |
2943 | if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) |
2945 | if (tmp->title || tmp->flag [FLAG_CURSED]) |
2944 | eat_special_food (op, tmp); |
2946 | eat_special_food (op, tmp); |
2945 | } |
2947 | } |
2946 | } |
2948 | } |
2947 | |
2949 | |
2948 | handle_apply_yield (tmp); |
2950 | handle_apply_yield (tmp); |
… | |
… | |
2954 | * Does some sanity checks, then calls improve_armour. |
2956 | * Does some sanity checks, then calls improve_armour. |
2955 | */ |
2957 | */ |
2956 | static void |
2958 | static void |
2957 | apply_armour_improver (object *op, object *tmp) |
2959 | apply_armour_improver (object *op, object *tmp) |
2958 | { |
2960 | { |
2959 | object *armor; |
|
|
2960 | |
|
|
2961 | if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2961 | if (!op->flag [FLAG_WIZCAST] && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC)) |
2962 | { |
2962 | { |
2963 | op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2963 | op->failmsg ("Something blocks the magic of the scroll. H<This area prevents magic effects.>"); |
2964 | return; |
2964 | return; |
2965 | } |
2965 | } |
2966 | |
2966 | |
2967 | armor = find_marked_object (op); |
2967 | object *armor = op->mark (); |
2968 | |
2968 | |
2969 | if (!armor) |
2969 | if (!armor) |
2970 | { |
2970 | { |
2971 | op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2971 | op->failmsg ("You need to mark an armor object. Use the right mouse button popup or the mark command to do this."); |
2972 | return; |
2972 | return; |
… | |
… | |
2975 | if (armor->type != ARMOUR |
2975 | if (armor->type != ARMOUR |
2976 | && armor->type != CLOAK |
2976 | && armor->type != CLOAK |
2977 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2977 | && armor->type != BOOTS && armor->type != GLOVES && armor->type != BRACERS && armor->type != SHIELD && armor->type != HELMET) |
2978 | { |
2978 | { |
2979 | op->failmsg ("Your marked item is not armour!\n"); |
2979 | op->failmsg ("Your marked item is not armour!\n"); |
|
|
2980 | return; |
|
|
2981 | } |
|
|
2982 | |
|
|
2983 | if (!op->apply (armor, AP_UNAPPLY)) |
|
|
2984 | { |
|
|
2985 | op->failmsg ("You are unable to take off your armour to improve it!"); |
2980 | return; |
2986 | return; |
2981 | } |
2987 | } |
2982 | |
2988 | |
2983 | op->statusmsg ("Applying armour enchantment."); |
2989 | op->statusmsg ("Applying armour enchantment."); |
2984 | improve_armour (op, tmp, armor); |
2990 | improve_armour (op, tmp, armor); |
… | |
… | |
3070 | * the selected object to "burn". -b.t. |
3076 | * the selected object to "burn". -b.t. |
3071 | */ |
3077 | */ |
3072 | static void |
3078 | static void |
3073 | apply_lighter (object *who, object *lighter) |
3079 | apply_lighter (object *who, object *lighter) |
3074 | { |
3080 | { |
3075 | object *item; |
|
|
3076 | int is_player_env = 0; |
3081 | int is_player_env = 0; |
3077 | |
3082 | |
3078 | item = find_marked_object (who); |
3083 | if (object *item = who->mark ()) |
3079 | if (item) |
|
|
3080 | { |
3084 | { |
3081 | if (!auto_apply_lighter (who, item, lighter)) |
3085 | if (!auto_apply_lighter (who, item, lighter)) |
3082 | return; |
3086 | return; |
3083 | |
3087 | |
3084 | /* Perhaps we should split what we are trying to light on fire? |
3088 | /* Perhaps we should split what we are trying to light on fire? |
… | |
… | |
3275 | * The 'slaying' field for transformer is used as verb for the action. |
3279 | * The 'slaying' field for transformer is used as verb for the action. |
3276 | */ |
3280 | */ |
3277 | static void |
3281 | static void |
3278 | apply_item_transformer (object *pl, object *transformer) |
3282 | apply_item_transformer (object *pl, object *transformer) |
3279 | { |
3283 | { |
3280 | object *marked; |
|
|
3281 | object *new_item; |
3284 | object *new_item; |
3282 | const char *find; |
3285 | const char *find; |
3283 | char *separator; |
3286 | char *separator; |
3284 | int yield; |
3287 | int yield; |
3285 | char got[MAX_BUF]; |
3288 | char got[MAX_BUF]; |
3286 | int len; |
3289 | int len; |
3287 | |
3290 | |
3288 | if (!pl || !transformer) |
3291 | if (!pl || !transformer) |
3289 | return; |
3292 | return; |
3290 | |
3293 | |
3291 | marked = find_marked_object (pl); |
3294 | object *marked = pl->mark (); |
3292 | |
3295 | |
3293 | if (!marked) |
3296 | if (!marked) |
3294 | { |
3297 | { |
3295 | pl->failmsgf ("Use the %s with what item?", query_name (transformer)); |
3298 | pl->failmsgf ("Use the %s with what item?", query_name (transformer)); |
3296 | return; |
3299 | return; |
… | |
… | |
3733 | auto_apply (object *op) |
3736 | auto_apply (object *op) |
3734 | { |
3737 | { |
3735 | object *tmp = NULL, *tmp2; |
3738 | object *tmp = NULL, *tmp2; |
3736 | int i; |
3739 | int i; |
3737 | |
3740 | |
3738 | CLEAR_FLAG (op, FLAG_AUTO_APPLY); |
3741 | op->clr_flag (FLAG_AUTO_APPLY); |
3739 | |
3742 | |
3740 | switch (op->type) |
3743 | switch (op->type) |
3741 | { |
3744 | { |
3742 | case SHOP_FLOOR: |
3745 | case SHOP_FLOOR: |
3743 | if (!op->has_random_items ()) |
3746 | if (!op->has_random_items ()) |
… | |
… | |
3753 | == NULL && --i); |
3756 | == NULL && --i); |
3754 | |
3757 | |
3755 | if (tmp == NULL) |
3758 | if (tmp == NULL) |
3756 | return 0; |
3759 | return 0; |
3757 | |
3760 | |
3758 | if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) |
3761 | if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED]) |
3759 | { |
3762 | { |
3760 | tmp->destroy (); |
3763 | tmp->destroy (); |
3761 | tmp = NULL; |
3764 | tmp = NULL; |
3762 | } |
3765 | } |
3763 | } |
3766 | } |
3764 | while (!tmp); |
3767 | while (!tmp); |
3765 | |
3768 | |
3766 | tmp->x = op->x; |
3769 | tmp->x = op->x; |
3767 | tmp->y = op->y; |
3770 | tmp->y = op->y; |
3768 | SET_FLAG (tmp, FLAG_UNPAID); |
3771 | tmp->set_flag (FLAG_UNPAID); |
3769 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3772 | insert_ob_in_map (tmp, op->map, NULL, 0); |
3770 | identify (tmp); |
3773 | identify (tmp); |
3771 | break; |
3774 | break; |
3772 | |
3775 | |
3773 | case TREASURE: |
3776 | case TREASURE: |
3774 | if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) |
3777 | if (op->flag [FLAG_IS_A_TEMPLATE]) |
3775 | return 0; |
3778 | return 0; |
3776 | |
3779 | |
3777 | while (op->stats.hp-- > 0) |
3780 | while (op->stats.hp-- > 0) |
3778 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3781 | create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, |
3779 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
3782 | op->stats.exp ? (int) op->stats.exp : op->map == NULL ? 14 : op->map->difficulty, 0); |
… | |
… | |
3817 | |
3820 | |
3818 | for (invtmp = tmp->inv; invtmp; invtmp = invnext) |
3821 | for (invtmp = tmp->inv; invtmp; invtmp = invnext) |
3819 | { |
3822 | { |
3820 | invnext = invtmp->below; |
3823 | invnext = invtmp->below; |
3821 | |
3824 | |
3822 | if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) |
3825 | if (invtmp->flag [FLAG_AUTO_APPLY]) |
3823 | auto_apply (invtmp); |
3826 | auto_apply (invtmp); |
3824 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3827 | else if (invtmp->type == TREASURE && invtmp->has_random_items ()) |
3825 | { |
3828 | { |
3826 | while (invtmp->stats.hp-- > 0) |
3829 | while (invtmp->stats.hp-- > 0) |
3827 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
3830 | create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); |
… | |
… | |
3852 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3855 | if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL |
3853 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3856 | || tmp->type == HORN || tmp->type == FIREWALL || tmp->type == POTION || tmp->type == ALTAR || tmp->type == SPELLBOOK) |
3854 | tmp->randomitems = NULL; |
3857 | tmp->randomitems = NULL; |
3855 | } |
3858 | } |
3856 | |
3859 | |
3857 | if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) |
3860 | if (tmp->flag [FLAG_AUTO_APPLY]) |
3858 | auto_apply (tmp); |
3861 | auto_apply (tmp); |
3859 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3862 | else if ((tmp->type == TREASURE || (tmp->type == CONTAINER)) && tmp->has_random_items ()) |
3860 | { |
3863 | { |
3861 | while ((tmp->stats.hp--) > 0) |
3864 | while ((tmp->stats.hp--) > 0) |
3862 | create_treasure (tmp->randomitems, tmp, 0, difficulty, 0); |
3865 | create_treasure (tmp->randomitems, tmp, 0, difficulty, 0); |
… | |
… | |
3864 | } |
3867 | } |
3865 | else if (tmp->type == TIMED_GATE) |
3868 | else if (tmp->type == TIMED_GATE) |
3866 | { |
3869 | { |
3867 | object *head = tmp->head != NULL ? tmp->head : tmp; |
3870 | object *head = tmp->head != NULL ? tmp->head : tmp; |
3868 | |
3871 | |
3869 | if (QUERY_FLAG (head, FLAG_IS_LINKED)) |
3872 | if (head->flag [FLAG_IS_LINKED]) |
3870 | tmp->set_speed (0); |
3873 | tmp->set_speed (0); |
3871 | } |
3874 | } |
3872 | /* This function can be called everytime a map is loaded, even when |
3875 | /* This function can be called everytime a map is loaded, even when |
3873 | * swapping back in. As such, we don't want to create the treasure |
3876 | * swapping back in. As such, we don't want to create the treasure |
3874 | * over and ove again, so after we generate the treasure, blank out |
3877 | * over and ove again, so after we generate the treasure, blank out |
… | |
… | |
3963 | } |
3966 | } |
3964 | |
3967 | |
3965 | /* check for hp, sp change */ |
3968 | /* check for hp, sp change */ |
3966 | if (food->stats.hp != 0) |
3969 | if (food->stats.hp != 0) |
3967 | { |
3970 | { |
3968 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3971 | if (food->flag [FLAG_CURSED]) |
3969 | { |
3972 | { |
3970 | who->contr->killer = food; |
3973 | who->contr->killer = food; |
3971 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3974 | hit_player (who, food->stats.hp, food, AT_POISON, 1); |
3972 | who->failmsg ("Eck!...that was poisonous!"); |
3975 | who->failmsg ("Eck!...that was poisonous!"); |
3973 | } |
3976 | } |
… | |
… | |
3982 | } |
3985 | } |
3983 | } |
3986 | } |
3984 | |
3987 | |
3985 | if (food->stats.sp != 0) |
3988 | if (food->stats.sp != 0) |
3986 | { |
3989 | { |
3987 | if (QUERY_FLAG (food, FLAG_CURSED)) |
3990 | if (food->flag [FLAG_CURSED]) |
3988 | { |
3991 | { |
3989 | who->failmsg ("You are drained of mana!"); |
3992 | who->failmsg ("You are drained of mana!"); |
3990 | who->stats.sp -= food->stats.sp; |
3993 | who->stats.sp -= food->stats.sp; |
3991 | if (who->stats.sp < 0) |
3994 | if (who->stats.sp < 0) |
3992 | who->stats.sp = 0; |
3995 | who->stats.sp = 0; |
… | |
… | |
4075 | pl->animation_id = change->animation_id; |
4078 | pl->animation_id = change->animation_id; |
4076 | pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; |
4079 | pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; |
4077 | } |
4080 | } |
4078 | |
4081 | |
4079 | /* check the special case of can't use weapons */ |
4082 | /* check the special case of can't use weapons */ |
4080 | /*if(QUERY_FLAG(change,FLAG_USE_WEAPON)) CLEAR_FLAG(pl,FLAG_USE_WEAPON); */ |
4083 | /*if(change->flag [FLAG_USE_WEAPON]) pl->clr_flag (FLAG_USE_WEAPON); */ |
4081 | if (change->name == shstr_monk) |
4084 | if (change->name == shstr_monk) |
4082 | CLEAR_FLAG (pl, FLAG_USE_WEAPON); |
4085 | pl->clr_flag (FLAG_USE_WEAPON); |
4083 | |
4086 | |
4084 | break; |
4087 | break; |
4085 | } |
4088 | } |
4086 | } |
4089 | } |
4087 | } |
4090 | } |