ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/apply.C
(Generate patch)

Comparing deliantra/server/server/apply.C (file contents):
Revision 1.252 by root, Sat Apr 10 04:54:09 2010 UTC vs.
Revision 1.257 by root, Thu Apr 15 00:36:51 2010 UTC

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 */
426static int 426static int
427check_improve_weapon (object *op, object *tmp) 427check_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 */
483static int 487static int
484improve_armour (object *op, object *improver, object *armour) 488improve_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
1075 who->statusmsg (format ("You unready %s.", query_name (op))); 1077 who->statusmsg (format ("You unready %s.", query_name (op)));
1076 change_abil (who, op); 1078 change_abil (who, op);
1077 } 1079 }
1078 else 1080 else
1079 { 1081 {
1080 who->change_skill (0);
1081
1082 if (op->type == BOW) 1082 if (op->type == BOW)
1083 op->flag [FLAG_READY_BOW ] = false; 1083 op->flag [FLAG_READY_BOW ] = false;
1084 else 1084 else
1085 op->flag [FLAG_READY_RANGE] = false; 1085 op->flag [FLAG_READY_RANGE] = false;
1086 } 1086 }
1167static bool 1167static bool
1168unapply_for_ob (object *who, object *op, int aflags) 1168unapply_for_ob (object *who, object *op, int aflags)
1169{ 1169{
1170 if (op->is_range ()) 1170 if (op->is_range ())
1171 for (object *tmp = who->inv; tmp; tmp = tmp->below) 1171 for (object *tmp = who->inv; tmp; tmp = tmp->below)
1172 if (QUERY_FLAG (tmp, FLAG_APPLIED) && tmp->is_range ()) 1172 if (tmp->flag [FLAG_APPLIED] && tmp->is_range ())
1173 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]))
1174 { 1174 {
1175 if (aflags & AP_PRINT) 1175 if (aflags & AP_PRINT)
1176 who->failmsg (query_name (tmp)); 1176 who->failmsg (query_name (tmp));
1177 else 1177 else
1178 unapply_special (who, tmp, aflags); 1178 unapply_special (who, tmp, aflags);
1211#endif 1211#endif
1212 return 1; 1212 return 1;
1213 } 1213 }
1214 1214
1215 /* 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 */
1216 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])))
1217 { 1217 {
1218 if (aflags & AP_PRINT) 1218 if (aflags & AP_PRINT)
1219 who->failmsg (query_name (tmp)); 1219 who->failmsg (query_name (tmp));
1220 else 1220 else
1221 unapply_special (who, tmp, aflags); 1221 unapply_special (who, tmp, aflags);
1333 * the weapon/shield checks, and the range checks for monsters, 1333 * the weapon/shield checks, and the range checks for monsters,
1334 * 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,
1335 * 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
1336 * all use the same location. 1336 * all use the same location.
1337 */ 1337 */
1338 if (op->type == WEAPON && !QUERY_FLAG (who, FLAG_USE_WEAPON)) 1338 if (op->type == WEAPON && !who->flag [FLAG_USE_WEAPON])
1339 retval |= CAN_APPLY_RESTRICTION; 1339 retval |= CAN_APPLY_RESTRICTION;
1340 1340
1341 if (op->type == SHIELD && !QUERY_FLAG (who, FLAG_USE_SHIELD)) 1341 if (op->type == SHIELD && !who->flag [FLAG_USE_SHIELD])
1342 retval |= CAN_APPLY_RESTRICTION; 1342 retval |= CAN_APPLY_RESTRICTION;
1343 1343
1344 if (who->type != PLAYER) 1344 if (who->type != PLAYER)
1345 { 1345 {
1346 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])
1347 retval |= CAN_APPLY_RESTRICTION; 1347 retval |= CAN_APPLY_RESTRICTION;
1348 1348
1349 if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) 1349 if (op->type == BOW && !who->flag [FLAG_USE_BOW])
1350 retval |= CAN_APPLY_RESTRICTION; 1350 retval |= CAN_APPLY_RESTRICTION;
1351 1351
1352 if (op->type == RING && !QUERY_FLAG (who, FLAG_USE_RING)) 1352 if (op->type == RING && !who->flag [FLAG_USE_RING])
1353 retval |= CAN_APPLY_RESTRICTION; 1353 retval |= CAN_APPLY_RESTRICTION;
1354 1354
1355 if (op->type == BOW && !QUERY_FLAG (who, FLAG_USE_BOW)) 1355 if (op->type == BOW && !who->flag [FLAG_USE_BOW])
1356 retval |= CAN_APPLY_RESTRICTION; 1356 retval |= CAN_APPLY_RESTRICTION;
1357 } 1357 }
1358 1358
1359 return retval; 1359 return retval;
1360} 1360}
1401 //TODO: remove these when apply_special is no longer exposed 1401 //TODO: remove these when apply_special is no longer exposed
1402 if (op->env != who) 1402 if (op->env != who)
1403 return 1; /* op is not in inventory */ 1403 return 1; /* op is not in inventory */
1404 1404
1405 /* trying to unequip op */ 1405 /* trying to unequip op */
1406 if (QUERY_FLAG (op, FLAG_APPLIED)) 1406 if (op->flag [FLAG_APPLIED])
1407 { 1407 {
1408 /* always apply, so no reason to unapply */ 1408 /* always apply, so no reason to unapply */
1409 if (basic_flag == AP_APPLY) 1409 if (basic_flag == AP_APPLY)
1410 return 0; 1410 return 0;
1411 1411
1412 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]))
1413 { 1413 {
1414 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));
1415 return 1; 1415 return 1;
1416 } 1416 }
1417 1417
1512 if (player *pl = who->contr) 1512 if (player *pl = who->contr)
1513 { 1513 {
1514 who->statusmsg (format ("You wield %s.", query_name (op))); 1514 who->statusmsg (format ("You wield %s.", query_name (op)));
1515 change_abil (who, op); 1515 change_abil (who, op);
1516 } 1516 }
1517 else
1518 who->change_skill (skop);
1519 1517
1520 op->flag [FLAG_READY_WEAPON] = true; 1518 op->flag [FLAG_READY_WEAPON] = true;
1521 break; 1519 break;
1522 1520
1523 case ARMOUR: 1521 case ARMOUR:
1528 case GIRDLE: 1526 case GIRDLE:
1529 case BRACERS: 1527 case BRACERS:
1530 case CLOAK: 1528 case CLOAK:
1531 case RING: 1529 case RING:
1532 case AMULET: 1530 case AMULET:
1533 SET_FLAG (op, FLAG_APPLIED); 1531 op->set_flag (FLAG_APPLIED);
1534 who->statusmsg (format ("You wear %s.", query_name (op))); 1532 who->statusmsg (format ("You wear %s.", query_name (op)));
1535 change_abil (who, op); 1533 change_abil (who, op);
1536 break; 1534 break;
1537 1535
1538 case SKILL_TOOL: 1536 case SKILL_TOOL:
1539 // applying a skill tool does not ready the skill 1537 // applying a skill tool does not ready the skill
1540 // if something needs the skill, it has to ready it itself 1538 // if something needs the skill, it has to ready it itself
1541 //TODO: unapplying should unapply the skill, though 1539 //TODO: unapplying should unapply the skill, though
1542 SET_FLAG (op, FLAG_APPLIED); 1540 op->set_flag (FLAG_APPLIED);
1543 break; 1541 break;
1544 1542
1545 case SKILL: 1543 case SKILL:
1546 if (!(aflags & AP_NO_SLOT)) 1544 if (!(aflags & AP_NO_SLOT))
1547 { 1545 {
1585 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));
1586 else 1584 else
1587 who->statusmsg (format ("You ready %s.", query_name (op))); 1585 who->statusmsg (format ("You ready %s.", query_name (op)));
1588 } 1586 }
1589 1587
1590 SET_FLAG (who, FLAG_READY_SKILL); 1588 who->set_flag (FLAG_READY_SKILL);
1591 SET_FLAG (op, FLAG_APPLIED); 1589 op->set_flag (FLAG_APPLIED);
1592 change_abil (who, op); 1590 change_abil (who, op);
1593 break; 1591 break;
1594 1592
1595 case BOW: 1593 case BOW:
1596 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 ()] != '\''))
1640 1638
1641 change_abil (who, op); 1639 change_abil (who, op);
1642 } 1640 }
1643 else 1641 else
1644 { 1642 {
1645 who->change_skill (skop);
1646
1647 if (op->type == BOW) 1643 if (op->type == BOW)
1648 op->flag [FLAG_READY_BOW ] = true; 1644 op->flag [FLAG_READY_BOW ] = true;
1649 else 1645 else
1650 op->flag [FLAG_READY_RANGE] = true; 1646 op->flag [FLAG_READY_RANGE] = true;
1651 } 1647 }
1662 1658
1663 default: 1659 default:
1664 who->statusmsg (format ("You apply %s.", query_name (op))); 1660 who->statusmsg (format ("You apply %s.", query_name (op)));
1665 } 1661 }
1666 1662
1667 SET_FLAG (op, FLAG_APPLIED); 1663 op->set_flag (FLAG_APPLIED);
1668 1664
1669 if (tmp) who->insert (tmp); 1665 if (tmp) who->insert (tmp);
1670 1666
1671 who->update_stats (); 1667 who->update_stats ();
1672 1668
1673 /* We exclude spell casting objects. The fire code will set the 1669 /* We exclude spell casting objects. The fire code will set the
1674 * been applied flag when they are used - until that point, 1670 * been applied flag when they are used - until that point,
1675 * you don't know anything about them. 1671 * you don't know anything about them.
1676 */ 1672 */
1677 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)
1678 SET_FLAG (op, FLAG_BEEN_APPLIED); 1674 op->set_flag (FLAG_BEEN_APPLIED);
1679 1675
1680 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 1676 if (op->flag [FLAG_CURSED] || op->flag [FLAG_DAMNED])
1681 if (who->type == PLAYER) 1677 if (who->type == PLAYER)
1682 { 1678 {
1683 who->failmsg ( 1679 who->failmsg (
1684 "Oops, it feels deadly cold! " 1680 "Oops, it feels deadly cold! "
1685 "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.>"
1686 ); 1682 );
1687 SET_FLAG (op, FLAG_KNOWN_CURSED); 1683 op->set_flag (FLAG_KNOWN_CURSED);
1688 } 1684 }
1689 1685
1690 if (object *pl = op->visible_to ()) 1686 if (object *pl = op->visible_to ())
1691 esrv_send_item (pl, op); 1687 esrv_send_item (pl, op);
1692 1688
1765 return 0; 1761 return 0;
1766 1762
1767 /* 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
1768 * identified. If it doesn't, then go through the player inventory. 1764 * identified. If it doesn't, then go through the player inventory.
1769 */ 1765 */
1770 if (object *marked = find_marked_object (pl)) 1766 if (object *marked = pl->mark ())
1771 if (!QUERY_FLAG (marked, FLAG_IDENTIFIED) && need_identify (marked)) 1767 if (!marked->flag [FLAG_IDENTIFIED] && need_identify (marked))
1772 { 1768 {
1773 if (operate_altar (altar, &money, pl)) 1769 if (operate_altar (altar, &money, pl))
1774 { 1770 {
1775 identify (marked); 1771 identify (marked);
1776 1772
1782 } 1778 }
1783 } 1779 }
1784 1780
1785 for (object *id = pl->inv; id; id = id->below) 1781 for (object *id = pl->inv; id; id = id->below)
1786 { 1782 {
1787 if (!QUERY_FLAG (id, FLAG_IDENTIFIED) && !id->invisible && need_identify (id)) 1783 if (!id->flag [FLAG_IDENTIFIED] && !id->invisible && need_identify (id))
1788 { 1784 {
1789 if (operate_altar (altar, &money, pl)) 1785 if (operate_altar (altar, &money, pl))
1790 { 1786 {
1791 identify (id); 1787 identify (id);
1792 1788
1838 1834
1839 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)
1840 { 1836 {
1841 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!");
1842 1838
1843 CLEAR_FLAG (tmp, FLAG_APPLIED); 1839 tmp->clr_flag (FLAG_APPLIED);
1844 return 0; 1840 return 0;
1845 } 1841 }
1846 1842
1847 if (op->type == PLAYER) 1843 if (op->type == PLAYER)
1848 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 1844 if (!tmp->flag [FLAG_IDENTIFIED])
1849 identify (tmp); 1845 identify (tmp);
1850 1846
1851 handle_apply_yield (tmp); 1847 handle_apply_yield (tmp);
1852 1848
1853 /* Potion of restoration - only for players */ 1849 /* Potion of restoration - only for players */
1854 if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE)) 1850 if (op->type == PLAYER && (tmp->attacktype & AT_DEPLETE))
1855 { 1851 {
1856 object *depl; 1852 object *depl;
1857 archetype *at; 1853 archetype *at;
1858 1854
1859 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 1855 if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED])
1860 { 1856 {
1861 op->drain_stat (); 1857 op->drain_stat ();
1862 op->update_stats (); 1858 op->update_stats ();
1863 tmp->decrease (); 1859 tmp->decrease ();
1864 return 1; 1860 return 1;
1891 /* improvement potion - only for players */ 1887 /* improvement potion - only for players */
1892 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER)) 1888 if (op->type == PLAYER && (tmp->attacktype & AT_GODPOWER))
1893 { 1889 {
1894 for (i = 1; i < min (11, op->level); i++) 1890 for (i = 1; i < min (11, op->level); i++)
1895 { 1891 {
1896 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 1892 if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED])
1897 { 1893 {
1898 if (op->contr->levhp[i] != 1) 1894 if (op->contr->levhp[i] != 1)
1899 { 1895 {
1900 op->contr->levhp[i] = 1; 1896 op->contr->levhp[i] = 1;
1901 break; 1897 break;
1937 1933
1938 /* Just makes checking easier */ 1934 /* Just makes checking easier */
1939 if (i < min (11, op->level)) 1935 if (i < min (11, op->level))
1940 got_one = 1; 1936 got_one = 1;
1941 1937
1942 if (!QUERY_FLAG (tmp, FLAG_CURSED) && !QUERY_FLAG (tmp, FLAG_DAMNED)) 1938 if (!tmp->flag [FLAG_CURSED] && !tmp->flag [FLAG_DAMNED])
1943 { 1939 {
1944 if (got_one) 1940 if (got_one)
1945 { 1941 {
1946 op->update_stats (); 1942 op->update_stats ();
1947 op->statusmsg ("The Gods smile upon you and remake you " 1943 op->statusmsg ("The Gods smile upon you and remake you "
1972 * 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,
1973 * 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.
1974 */ 1970 */
1975 if (tmp->inv) 1971 if (tmp->inv)
1976 { 1972 {
1977 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 1973 if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED])
1978 { 1974 {
1979 op->failmsg ("Yech! Your lungs are on fire!"); 1975 op->failmsg ("Yech! Your lungs are on fire!");
1980 create_exploding_ball_at (op, op->level); 1976 create_exploding_ball_at (op, op->level);
1981 } 1977 }
1982 else 1978 else
1983 cast_spell (op, tmp, op->facing, tmp->inv, NULL); 1979 cast_spell (op, tmp, op->facing, tmp->inv, NULL);
1984 1980
1985 tmp->decrease (); 1981 tmp->decrease ();
1986 1982
1987 /* if youre dead, no point in doing this... */ 1983 /* if youre dead, no point in doing this... */
1988 if (!QUERY_FLAG (op, FLAG_REMOVED)) 1984 if (!op->flag [FLAG_REMOVED])
1989 op->update_stats (); 1985 op->update_stats ();
1990 1986
1991 return 1; 1987 return 1;
1992 } 1988 }
1993 1989
2008 2004
2009 /* This is a protection potion */ 2005 /* This is a protection potion */
2010 if (force) 2006 if (force)
2011 { 2007 {
2012 /* cursed items last longer */ 2008 /* cursed items last longer */
2013 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 2009 if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED])
2014 { 2010 {
2015 force->stats.food *= 10; 2011 force->stats.food *= 10;
2016 for (i = 0; i < NROFATTACKS; i++) 2012 for (i = 0; i < NROFATTACKS; i++)
2017 if (force->resist[i] > 0) 2013 if (force->resist[i] > 0)
2018 force->resist[i] = -force->resist[i]; /* prot => vuln */ 2014 force->resist[i] = -force->resist[i]; /* prot => vuln */
2019 } 2015 }
2020 2016
2021 force->speed_left = -1; 2017 force->speed_left = -1;
2022 force = insert_ob_in_ob (force, op); 2018 force = insert_ob_in_ob (force, op);
2023 CLEAR_FLAG (tmp, FLAG_APPLIED); 2019 tmp->clr_flag (FLAG_APPLIED);
2024 SET_FLAG (force, FLAG_APPLIED); 2020 force->set_flag (FLAG_APPLIED);
2025 change_abil (op, force); 2021 change_abil (op, force);
2026 tmp->decrease (); 2022 tmp->decrease ();
2027 return 1; 2023 return 1;
2028 } 2024 }
2029 2025
2030 /* Only thing left are the stat potions */ 2026 /* Only thing left are the stat potions */
2031 if (op->type == PLAYER) 2027 if (op->type == PLAYER)
2032 { /* only for players */ 2028 { /* only for players */
2033 if ((QUERY_FLAG (tmp, FLAG_CURSED) 2029 if ((tmp->flag [FLAG_CURSED]
2034 || QUERY_FLAG (tmp, FLAG_DAMNED)) 2030 || tmp->flag [FLAG_DAMNED])
2035 && tmp->value != 0) 2031 && tmp->value != 0)
2036 CLEAR_FLAG (tmp, FLAG_APPLIED); 2032 tmp->clr_flag (FLAG_APPLIED);
2037 else 2033 else
2038 SET_FLAG (tmp, FLAG_APPLIED); 2034 tmp->set_flag (FLAG_APPLIED);
2039 2035
2040 if (!change_abil (op, tmp)) 2036 if (!change_abil (op, tmp))
2041 op->statusmsg ("Nothing happened."); 2037 op->statusmsg ("Nothing happened.");
2042 } 2038 }
2043 2039
2044 /* CLEAR_FLAG is so that if the character has other potions 2040 /* CLEAR_FLAG is so that if the character has other potions
2045 * that were grouped with the one consumed, his 2041 * that were grouped with the one consumed, his
2046 * stat will not be raised by them. fix_player just clears 2042 * stat will not be raised by them. fix_player just clears
2047 * up all the stats. 2043 * up all the stats.
2048 */ 2044 */
2049 CLEAR_FLAG (tmp, FLAG_APPLIED); 2045 tmp->clr_flag (FLAG_APPLIED);
2050 op->update_stats (); 2046 op->update_stats ();
2051 tmp->decrease (); 2047 tmp->decrease ();
2052 return 1; 2048 return 1;
2053} 2049}
2054 2050
2065move_apply (object *trap, object *victim, object *originator) 2061move_apply (object *trap, object *victim, object *originator)
2066{ 2062{
2067 static int recursion_depth = 0; 2063 static int recursion_depth = 0;
2068 2064
2069 /* Only exits affect DMs. */ 2065 /* Only exits affect DMs. */
2070 if (QUERY_FLAG (victim, FLAG_WIZPASS) && trap->type != EXIT && trap->type != SIGN) 2066 if (victim->flag [FLAG_WIZPASS] && trap->type != EXIT && trap->type != SIGN)
2071 return; 2067 return;
2072 2068
2073 /* move_apply() is the most likely candidate for causing unwanted and 2069 /* move_apply() is the most likely candidate for causing unwanted and
2074 * possibly unlimited recursion. 2070 * possibly unlimited recursion.
2075 */ 2071 */
2151 * 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.
2152 * 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
2153 * 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
2154 * action, we avoid hits here 2150 * action, we avoid hits here
2155 */ 2151 */
2156 if ((QUERY_FLAG (victim, FLAG_ALIVE) && trap->has_active_speed ()) 2152 if ((victim->flag [FLAG_ALIVE] && trap->has_active_speed ())
2157 && trap->owner != victim) 2153 && trap->owner != victim)
2158 hit_with_arrow (trap, victim); 2154 hit_with_arrow (trap, victim);
2159 break; 2155 break;
2160 2156
2161 case SPELL_EFFECT: 2157 case SPELL_EFFECT:
2269 apply_container (victim, trap); 2265 apply_container (victim, trap);
2270 break; 2266 break;
2271 2267
2272 case RUNE: 2268 case RUNE:
2273 case TRAP: 2269 case TRAP:
2274 if (trap->level && QUERY_FLAG (victim, FLAG_ALIVE)) 2270 if (trap->level && victim->flag [FLAG_ALIVE])
2275 spring_trap (trap, victim); 2271 spring_trap (trap, victim);
2276 break; 2272 break;
2277 2273
2278 default: 2274 default:
2279 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 "
2291apply_book (object *op, object *tmp) 2287apply_book (object *op, object *tmp)
2292{ 2288{
2293 int lev_diff; 2289 int lev_diff;
2294 object *skill_ob; 2290 object *skill_ob;
2295 2291
2296 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) 2292 if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ])
2297 { 2293 {
2298 op->failmsg ("You are unable to read while blind!"); 2294 op->failmsg ("You are unable to read while blind!");
2299 return; 2295 return;
2300 } 2296 }
2301 2297
2312 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);
2313 return; 2309 return;
2314 } 2310 }
2315 2311
2316 lev_diff = tmp->level - (skill_ob->level + 5); 2312 lev_diff = tmp->level - (skill_ob->level + 5);
2317 if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) 2313 if (!op->flag [FLAG_WIZ] && lev_diff > 0)
2318 { 2314 {
2319 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."
2320 : lev_diff < 3 ? "This book is slightly beyond your comprehension." 2316 : lev_diff < 3 ? "This book is slightly beyond your comprehension."
2321 : lev_diff < 5 ? "This book is beyond your comprehension." 2317 : lev_diff < 5 ? "This book is beyond your comprehension."
2322 : 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."
2333 if (player *pl = op->contr) 2329 if (player *pl = op->contr)
2334 if (client *ns = pl->ns) 2330 if (client *ns = pl->ns)
2335 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));
2336 2332
2337 /* gain xp from reading */ 2333 /* gain xp from reading */
2338 if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT)) 2334 if (!tmp->flag [FLAG_NO_SKILL_IDENT])
2339 { /* only if not read before */ 2335 { /* only if not read before */
2340 int exp_gain = calc_skill_exp (op, tmp, skill_ob); 2336 int exp_gain = calc_skill_exp (op, tmp, skill_ob);
2341 2337
2342 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 2338 if (!tmp->flag [FLAG_IDENTIFIED])
2343 { 2339 {
2344 /*exp_gain *= 2; because they just identified it too */ 2340 /*exp_gain *= 2; because they just identified it too */
2345 SET_FLAG (tmp, FLAG_IDENTIFIED); 2341 tmp->set_flag (FLAG_IDENTIFIED);
2346 2342
2347 if (object *pl = tmp->visible_to ()) 2343 if (object *pl = tmp->visible_to ())
2348 esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp); 2344 esrv_update_item (UPD_FLAGS | UPD_NAME, pl, tmp);
2349 } 2345 }
2350 2346
2351 change_exp (op, exp_gain, skill_ob->skill, 0); 2347 change_exp (op, exp_gain, skill_ob->skill, 0);
2352 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 */
2353 } 2349 }
2354} 2350}
2355 2351
2356/** 2352/**
2357 * 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.
2450 } 2446 }
2451 2447
2452 /* Upgrade special prayers to normal prayers */ 2448 /* Upgrade special prayers to normal prayers */
2453 if ((tmp = check_spell_known (op, spell->name)) != NULL) 2449 if ((tmp = check_spell_known (op, spell->name)) != NULL)
2454 { 2450 {
2455 if (special_prayer && !QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 2451 if (special_prayer && !tmp->flag [FLAG_STARTEQUIP])
2456 { 2452 {
2457 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");
2458 return; 2454 return;
2459 } 2455 }
2460 return; 2456 return;
2464 2460
2465 tmp = spell->clone (); 2461 tmp = spell->clone ();
2466 insert_ob_in_ob (tmp, op); 2462 insert_ob_in_ob (tmp, op);
2467 2463
2468 if (special_prayer) 2464 if (special_prayer)
2469 SET_FLAG (tmp, FLAG_STARTEQUIP); 2465 tmp->set_flag (FLAG_STARTEQUIP);
2470 2466
2471 esrv_add_spells (op->contr, tmp); 2467 esrv_add_spells (op->contr, tmp);
2472} 2468}
2473 2469
2474/** 2470/**
2503static void 2499static void
2504apply_spellbook (object *op, object *tmp) 2500apply_spellbook (object *op, object *tmp)
2505{ 2501{
2506 object *skop, *spell, *spell_skill; 2502 object *skop, *spell, *spell_skill;
2507 2503
2508 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) 2504 if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ])
2509 { 2505 {
2510 op->failmsg ("You are unable to read while blind."); 2506 op->failmsg ("You are unable to read while blind.");
2511 return; 2507 return;
2512 } 2508 }
2513 2509
2557 return; 2553 return;
2558 } 2554 }
2559 2555
2560 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));
2561 2557
2562 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 2558 if (!tmp->flag [FLAG_IDENTIFIED])
2563 identify (tmp); 2559 identify (tmp);
2564 2560
2565 /* 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
2566 * 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
2567 * 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
2600 * 3 -Automatically fail to learn if you read while confused 2596 * 3 -Automatically fail to learn if you read while confused
2601 * 2597 *
2602 * 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
2603 * literacy rate very useful! -b.t. 2599 * literacy rate very useful! -b.t.
2604 */ 2600 */
2605 if (QUERY_FLAG (op, FLAG_CONFUSED)) 2601 if (op->flag [FLAG_CONFUSED])
2606 { 2602 {
2607 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!");
2608 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));
2609 } 2605 }
2610 else if (QUERY_FLAG (tmp, FLAG_STARTEQUIP) || 2606 else if (tmp->flag [FLAG_STARTEQUIP] ||
2611 (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])
2612 { 2608 {
2613 op->statusmsg ("You succeed in learning the spell!", NDI_GREEN); 2609 op->statusmsg ("You succeed in learning the spell!", NDI_GREEN);
2614 do_learn_spell (op, spell, 0); 2610 do_learn_spell (op, spell, 0);
2615 2611
2616 /* xp gain to literacy for spell learning */ 2612 /* xp gain to literacy for spell learning */
2617 if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 2613 if (!tmp->flag [FLAG_STARTEQUIP])
2618 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);
2619 } 2615 }
2620 else 2616 else
2621 { 2617 {
2622 op->contr->play_sound (sound_find ("fumble_spell")); 2618 op->contr->play_sound (sound_find ("fumble_spell"));
2632void 2628void
2633apply_scroll (object *op, object *tmp, int dir) 2629apply_scroll (object *op, object *tmp, int dir)
2634{ 2630{
2635 object *skop; 2631 object *skop;
2636 2632
2637 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) 2633 if (op->flag [FLAG_BLIND] && !op->flag [FLAG_WIZ])
2638 { 2634 {
2639 op->failmsg ("You are unable to read while blind."); 2635 op->failmsg ("You are unable to read while blind.");
2640 return; 2636 return;
2641 } 2637 }
2642 2638
2652 int exp_gain = 0; 2648 int exp_gain = 0;
2653 2649
2654 /* hard code literacy - tmp->skill points to where the exp 2650 /* hard code literacy - tmp->skill points to where the exp
2655 * should go for anything killed by the spell. 2651 * should go for anything killed by the spell.
2656 */ 2652 */
2657 skop = find_skill_by_name (op, skill_names[SK_LITERACY]); 2653 skop = find_skill_by_name (op, shstr_literacy);
2658 2654
2659 if (!skop) 2655 if (!skop)
2660 { 2656 {
2661 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.>");
2662 return; 2658 return;
2663 } 2659 }
2664 2660
2665 if ((exp_gain = calc_skill_exp (op, tmp, skop))) 2661 if ((exp_gain = calc_skill_exp (op, tmp, skop)))
2666 change_exp (op, exp_gain, skop->skill, 0); 2662 change_exp (op, exp_gain, skop->skill, 0);
2667 } 2663 }
2668 2664
2669 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED)) 2665 if (!tmp->flag [FLAG_IDENTIFIED])
2670 identify (tmp); 2666 identify (tmp);
2671 2667
2672 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));
2673 2669
2674 cast_spell (op, tmp, dir, tmp->inv, NULL); 2670 cast_spell (op, tmp, dir, tmp->inv, NULL);
2705 2701
2706 treas->x = op->x; 2702 treas->x = op->x;
2707 treas->y = op->y; 2703 treas->y = op->y;
2708 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);
2709 2705
2710 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])
2711 spring_trap (treas, op); 2707 spring_trap (treas, op);
2712 2708
2713 /* If either player or container was destroyed, no need to do 2709 /* If either player or container was destroyed, no need to do
2714 * further processing. I think this should be enclused with 2710 * further processing. I think this should be enclused with
2715 * spring trap above, as I don't think there is otherwise 2711 * spring trap above, as I don't think there is otherwise
2914 : tmp->type == DRINK 2910 : tmp->type == DRINK
2915 ? sound_find ("eat_drink") 2911 ? sound_find ("eat_drink")
2916 : sound_find ("eat_food") 2912 : sound_find ("eat_food")
2917 ); 2913 );
2918 2914
2919 if (!QUERY_FLAG (tmp, FLAG_CURSED)) 2915 if (!tmp->flag [FLAG_CURSED])
2920 { 2916 {
2921 const char *buf; 2917 const char *buf;
2922 2918
2923 if (!op->is_dragon ()) 2919 if (!op->is_dragon ())
2924 { 2920 {
2944 min_it (op->stats.hp, op->stats.maxhp); 2940 min_it (op->stats.hp, op->stats.maxhp);
2945 min_it (op->stats.food, MAX_FOOD); 2941 min_it (op->stats.food, MAX_FOOD);
2946 } 2942 }
2947 2943
2948 /* special food hack -b.t. */ 2944 /* special food hack -b.t. */
2949 if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) 2945 if (tmp->title || tmp->flag [FLAG_CURSED])
2950 eat_special_food (op, tmp); 2946 eat_special_food (op, tmp);
2951 } 2947 }
2952 } 2948 }
2953 2949
2954 handle_apply_yield (tmp); 2950 handle_apply_yield (tmp);
2960 * Does some sanity checks, then calls improve_armour. 2956 * Does some sanity checks, then calls improve_armour.
2961 */ 2957 */
2962static void 2958static void
2963apply_armour_improver (object *op, object *tmp) 2959apply_armour_improver (object *op, object *tmp)
2964{ 2960{
2965 object *armor;
2966
2967 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))
2968 { 2962 {
2969 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.>");
2970 return; 2964 return;
2971 } 2965 }
2972 2966
2973 armor = find_marked_object (op); 2967 object *armor = op->mark ();
2974 2968
2975 if (!armor) 2969 if (!armor)
2976 { 2970 {
2977 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.");
2978 return; 2972 return;
2981 if (armor->type != ARMOUR 2975 if (armor->type != ARMOUR
2982 && armor->type != CLOAK 2976 && armor->type != CLOAK
2983 && 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)
2984 { 2978 {
2985 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!");
2986 return; 2986 return;
2987 } 2987 }
2988 2988
2989 op->statusmsg ("Applying armour enchantment."); 2989 op->statusmsg ("Applying armour enchantment.");
2990 improve_armour (op, tmp, armor); 2990 improve_armour (op, tmp, armor);
3076 * the selected object to "burn". -b.t. 3076 * the selected object to "burn". -b.t.
3077 */ 3077 */
3078static void 3078static void
3079apply_lighter (object *who, object *lighter) 3079apply_lighter (object *who, object *lighter)
3080{ 3080{
3081 object *item;
3082 int is_player_env = 0; 3081 int is_player_env = 0;
3083 3082
3084 item = find_marked_object (who); 3083 if (object *item = who->mark ())
3085 if (item)
3086 { 3084 {
3087 if (!auto_apply_lighter (who, item, lighter)) 3085 if (!auto_apply_lighter (who, item, lighter))
3088 return; 3086 return;
3089 3087
3090 /* 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?
3281 * 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.
3282 */ 3280 */
3283static void 3281static void
3284apply_item_transformer (object *pl, object *transformer) 3282apply_item_transformer (object *pl, object *transformer)
3285{ 3283{
3286 object *marked;
3287 object *new_item; 3284 object *new_item;
3288 const char *find; 3285 const char *find;
3289 char *separator; 3286 char *separator;
3290 int yield; 3287 int yield;
3291 char got[MAX_BUF]; 3288 char got[MAX_BUF];
3292 int len; 3289 int len;
3293 3290
3294 if (!pl || !transformer) 3291 if (!pl || !transformer)
3295 return; 3292 return;
3296 3293
3297 marked = find_marked_object (pl); 3294 object *marked = pl->mark ();
3298 3295
3299 if (!marked) 3296 if (!marked)
3300 { 3297 {
3301 pl->failmsgf ("Use the %s with what item?", query_name (transformer)); 3298 pl->failmsgf ("Use the %s with what item?", query_name (transformer));
3302 return; 3299 return;
3739auto_apply (object *op) 3736auto_apply (object *op)
3740{ 3737{
3741 object *tmp = NULL, *tmp2; 3738 object *tmp = NULL, *tmp2;
3742 int i; 3739 int i;
3743 3740
3744 CLEAR_FLAG (op, FLAG_AUTO_APPLY); 3741 op->clr_flag (FLAG_AUTO_APPLY);
3745 3742
3746 switch (op->type) 3743 switch (op->type)
3747 { 3744 {
3748 case SHOP_FLOOR: 3745 case SHOP_FLOOR:
3749 if (!op->has_random_items ()) 3746 if (!op->has_random_items ())
3759 == NULL && --i); 3756 == NULL && --i);
3760 3757
3761 if (tmp == NULL) 3758 if (tmp == NULL)
3762 return 0; 3759 return 0;
3763 3760
3764 if (QUERY_FLAG (tmp, FLAG_CURSED) || QUERY_FLAG (tmp, FLAG_DAMNED)) 3761 if (tmp->flag [FLAG_CURSED] || tmp->flag [FLAG_DAMNED])
3765 { 3762 {
3766 tmp->destroy (); 3763 tmp->destroy ();
3767 tmp = NULL; 3764 tmp = NULL;
3768 } 3765 }
3769 } 3766 }
3770 while (!tmp); 3767 while (!tmp);
3771 3768
3772 tmp->x = op->x; 3769 tmp->x = op->x;
3773 tmp->y = op->y; 3770 tmp->y = op->y;
3774 SET_FLAG (tmp, FLAG_UNPAID); 3771 tmp->set_flag (FLAG_UNPAID);
3775 insert_ob_in_map (tmp, op->map, NULL, 0); 3772 insert_ob_in_map (tmp, op->map, NULL, 0);
3776 identify (tmp); 3773 identify (tmp);
3777 break; 3774 break;
3778 3775
3779 case TREASURE: 3776 case TREASURE:
3780 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) 3777 if (op->flag [FLAG_IS_A_TEMPLATE])
3781 return 0; 3778 return 0;
3782 3779
3783 while (op->stats.hp-- > 0) 3780 while (op->stats.hp-- > 0)
3784 create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0, 3781 create_treasure (op->randomitems, op, op->map ? GT_ENVIRONMENT : 0,
3785 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);
3823 3820
3824 for (invtmp = tmp->inv; invtmp; invtmp = invnext) 3821 for (invtmp = tmp->inv; invtmp; invtmp = invnext)
3825 { 3822 {
3826 invnext = invtmp->below; 3823 invnext = invtmp->below;
3827 3824
3828 if (QUERY_FLAG (invtmp, FLAG_AUTO_APPLY)) 3825 if (invtmp->flag [FLAG_AUTO_APPLY])
3829 auto_apply (invtmp); 3826 auto_apply (invtmp);
3830 else if (invtmp->type == TREASURE && invtmp->has_random_items ()) 3827 else if (invtmp->type == TREASURE && invtmp->has_random_items ())
3831 { 3828 {
3832 while (invtmp->stats.hp-- > 0) 3829 while (invtmp->stats.hp-- > 0)
3833 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0); 3830 create_treasure (invtmp->randomitems, invtmp, 0, difficulty, 0);
3858 if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL 3855 if (tmp->type == WAND || tmp->type == ROD || tmp->type == SCROLL
3859 || 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)
3860 tmp->randomitems = NULL; 3857 tmp->randomitems = NULL;
3861 } 3858 }
3862 3859
3863 if (QUERY_FLAG (tmp, FLAG_AUTO_APPLY)) 3860 if (tmp->flag [FLAG_AUTO_APPLY])
3864 auto_apply (tmp); 3861 auto_apply (tmp);
3865 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 ())
3866 { 3863 {
3867 while ((tmp->stats.hp--) > 0) 3864 while ((tmp->stats.hp--) > 0)
3868 create_treasure (tmp->randomitems, tmp, 0, difficulty, 0); 3865 create_treasure (tmp->randomitems, tmp, 0, difficulty, 0);
3870 } 3867 }
3871 else if (tmp->type == TIMED_GATE) 3868 else if (tmp->type == TIMED_GATE)
3872 { 3869 {
3873 object *head = tmp->head != NULL ? tmp->head : tmp; 3870 object *head = tmp->head != NULL ? tmp->head : tmp;
3874 3871
3875 if (QUERY_FLAG (head, FLAG_IS_LINKED)) 3872 if (head->flag [FLAG_IS_LINKED])
3876 tmp->set_speed (0); 3873 tmp->set_speed (0);
3877 } 3874 }
3878 /* 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
3879 * 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
3880 * 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
3969 } 3966 }
3970 3967
3971 /* check for hp, sp change */ 3968 /* check for hp, sp change */
3972 if (food->stats.hp != 0) 3969 if (food->stats.hp != 0)
3973 { 3970 {
3974 if (QUERY_FLAG (food, FLAG_CURSED)) 3971 if (food->flag [FLAG_CURSED])
3975 { 3972 {
3976 who->contr->killer = food; 3973 who->contr->killer = food;
3977 hit_player (who, food->stats.hp, food, AT_POISON, 1); 3974 hit_player (who, food->stats.hp, food, AT_POISON, 1);
3978 who->failmsg ("Eck!...that was poisonous!"); 3975 who->failmsg ("Eck!...that was poisonous!");
3979 } 3976 }
3988 } 3985 }
3989 } 3986 }
3990 3987
3991 if (food->stats.sp != 0) 3988 if (food->stats.sp != 0)
3992 { 3989 {
3993 if (QUERY_FLAG (food, FLAG_CURSED)) 3990 if (food->flag [FLAG_CURSED])
3994 { 3991 {
3995 who->failmsg ("You are drained of mana!"); 3992 who->failmsg ("You are drained of mana!");
3996 who->stats.sp -= food->stats.sp; 3993 who->stats.sp -= food->stats.sp;
3997 if (who->stats.sp < 0) 3994 if (who->stats.sp < 0)
3998 who->stats.sp = 0; 3995 who->stats.sp = 0;
4081 pl->animation_id = change->animation_id; 4078 pl->animation_id = change->animation_id;
4082 pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE]; 4079 pl->flag [FLAG_ANIMATE] = change->flag [FLAG_ANIMATE];
4083 } 4080 }
4084 4081
4085 /* check the special case of can't use weapons */ 4082 /* check the special case of can't use weapons */
4086 /*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); */
4087 if (change->name == shstr_monk) 4084 if (change->name == shstr_monk)
4088 CLEAR_FLAG (pl, FLAG_USE_WEAPON); 4085 pl->clr_flag (FLAG_USE_WEAPON);
4089 4086
4090 break; 4087 break;
4091 } 4088 }
4092 } 4089 }
4093} 4090}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines