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.105 by root, Fri May 18 12:50:42 2007 UTC vs.
Revision 1.119 by elmex, Tue Jul 31 09:59:19 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by 9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * This program is distributed in the hope that it will be useful, 13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * You should have received a copy of the GNU General Public License 18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The authors can be reached via e-mail to <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 22 */
24 23
25#include <cmath> 24#include <cmath>
26 25
69 68
70 /* If the director has race set, only affect objects with a arch, 69 /* If the director has race set, only affect objects with a arch,
71 * name or race that matches. 70 * name or race that matches.
72 */ 71 */
73 if ((op->race) && 72 if ((op->race) &&
74 ((!(victim->arch && arch_flag && victim->arch->name) || op->race != victim->arch->name)) && 73 ((!(victim->arch && arch_flag && victim->arch->archname) || op->race != victim->arch->archname)) &&
75 ((!(victim->name && name_flag) || op->race != victim->name)) && 74 ((!(victim->name && name_flag) || op->race != victim->name)) &&
76 ((!(victim->race && race_flag) || op->race != victim->race))) 75 ((!(victim->race && race_flag) || op->race != victim->race)))
77 return 1; 76 return 1;
78 77
79 /* If the director has slaying set, only affect objects where none 78 /* If the director has slaying set, only affect objects where none
80 * of arch, name, or race match. 79 * of arch, name, or race match.
81 */ 80 */
82 if ((op->slaying) && (((victim->arch && arch_flag && victim->arch->name && op->slaying == victim->arch->name))) || 81 if ((op->slaying) && (((victim->arch && arch_flag && victim->arch->archname && op->slaying == victim->arch->archname))) ||
83 ((victim->name && name_flag && op->slaying == victim->name)) || 82 ((victim->name && name_flag && op->slaying == victim->name)) ||
84 ((victim->race && race_flag && op->slaying == victim->race))) 83 ((victim->race && race_flag && op->slaying == victim->race)))
85 return 1; 84 return 1;
86 85
87 return 0; 86 return 0;
158 157
159/** 158/**
160 * This checks whether the object has a "on_use_yield" field, and if so generated and drops 159 * This checks whether the object has a "on_use_yield" field, and if so generated and drops
161 * matching item. 160 * matching item.
162 **/ 161 **/
163static void 162void
164handle_apply_yield (object *tmp) 163handle_apply_yield (object *tmp)
165{ 164{
166 const char *yield; 165 const char *yield;
167 166
168 yield = get_ob_key_value (tmp, "on_use_yield"); 167 yield = get_ob_key_value (tmp, "on_use_yield");
425 return 0; 424 return 0;
426 425
427 op = op->below; 426 op = op->below;
428 while (op != NULL) 427 while (op != NULL)
429 { 428 {
430 if (strcmp (op->arch->name, item) == 0) 429 if (strcmp (op->arch->archname, item) == 0)
431 { 430 {
432 if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED) 431 if (!QUERY_FLAG (op, FLAG_CURSED) && !QUERY_FLAG (op, FLAG_DAMNED)
433 /* Loophole bug? -FD- */ && !QUERY_FLAG (op, FLAG_UNPAID)) 432 /* Loophole bug? -FD- */ && !QUERY_FLAG (op, FLAG_UNPAID))
434 { 433 {
435 if (op->nrof == 0) /* this is necessary for artifact sacrifices --FD-- */ 434 if (op->nrof == 0) /* this is necessary for artifact sacrifices --FD-- */
459 prev = op; 458 prev = op;
460 op = op->below; 459 op = op->below;
461 460
462 while (op != NULL) 461 while (op != NULL)
463 { 462 {
464 if (strcmp (op->arch->name, item) == 0) 463 if (strcmp (op->arch->archname, item) == 0)
465 { 464 {
466 if (op->nrof >= nrof) 465 if (op->nrof >= nrof)
467 { 466 {
468 decrease_ob_nr (op, nrof); 467 decrease_ob_nr (op, nrof);
469 return; 468 return;
576 op->update_stats (); 575 op->update_stats ();
577 return 1; 576 return 1;
578} 577}
579 578
580/* Types of improvements, hidden in the sp field. */ 579/* Types of improvements, hidden in the sp field. */
581#define IMPROVE_PREPARE 1 580#define IMPROVE_PREPARE 1
582#define IMPROVE_DAMAGE 2 581#define IMPROVE_DAMAGE 2
583#define IMPROVE_WEIGHT 3 582#define IMPROVE_WEIGHT 3
584#define IMPROVE_ENCHANT 4 583#define IMPROVE_ENCHANT 4
585#define IMPROVE_STR 5 584#define IMPROVE_STR 5
586#define IMPROVE_DEX 6 585#define IMPROVE_DEX 6
587#define IMPROVE_CON 7 586#define IMPROVE_CON 7
588#define IMPROVE_WIS 8 587#define IMPROVE_WIS 8
589#define IMPROVE_CHA 9 588#define IMPROVE_CHA 9
590#define IMPROVE_INT 10 589#define IMPROVE_INT 10
591#define IMPROVE_POW 11 590#define IMPROVE_POW 11
592
593 591
594/** 592/**
595 * This does the prepare weapon scroll. 593 * This does the prepare weapon scroll.
596 * Checks for sacrifice, and so on. 594 * Checks for sacrifice, and so on.
597 */ 595 */
598
599int 596int
600prepare_weapon (object *op, object *improver, object *weapon) 597prepare_weapon (object *op, object *improver, object *weapon)
601{ 598{
602 int sacrifice_count, i; 599 int sacrifice_count, i;
603 char buf[MAX_BUF]; 600 char buf[MAX_BUF];
605 if (weapon->level != 0) 602 if (weapon->level != 0)
606 { 603 {
607 new_draw_info (NDI_UNIQUE, 0, op, "Weapon already prepared."); 604 new_draw_info (NDI_UNIQUE, 0, op, "Weapon already prepared.");
608 return 0; 605 return 0;
609 } 606 }
607
610 for (i = 0; i < NROFATTACKS; i++) 608 for (i = 0; i < NROFATTACKS; i++)
611 if (weapon->resist[i]) 609 if (weapon->resist[i])
612 break; 610 break;
613 611
614 /* If we break out, i will be less than nrofattacks, preventing 612 /* If we break out, i will be less than nrofattacks, preventing
620 weapon->stats.ac) /* AC - only taifu's I think */ 618 weapon->stats.ac) /* AC - only taifu's I think */
621 { 619 {
622 new_draw_info (NDI_UNIQUE, 0, op, "Cannot prepare magic weapons."); 620 new_draw_info (NDI_UNIQUE, 0, op, "Cannot prepare magic weapons.");
623 return 0; 621 return 0;
624 } 622 }
623
625 sacrifice_count = check_sacrifice (op, improver); 624 sacrifice_count = check_sacrifice (op, improver);
626 if (sacrifice_count <= 0) 625 if (sacrifice_count <= 0)
627 return 0; 626 return 0;
627
628 weapon->level = isqrt (sacrifice_count); 628 weapon->level = isqrt (sacrifice_count);
629 new_draw_info (NDI_UNIQUE, 0, op, "Your sacrifice was accepted."); 629 new_draw_info (NDI_UNIQUE, 0, op, "Your sacrifice was accepted.");
630 eat_item (op, improver->slaying, sacrifice_count); 630 eat_item (op, improver->slaying, sacrifice_count);
631 631
632 new_draw_info_format (NDI_UNIQUE, 0, op, "Your *%s may be improved %d times.", &weapon->name, weapon->level); 632 new_draw_info_format (NDI_UNIQUE, 0, op, "Your *%s may be improved %d times.", &weapon->name, weapon->level);
855 { 855 {
856 base = base - (base * settings.armor_speed_improvement) / 100; 856 base = base - (base * settings.armor_speed_improvement) / 100;
857 pow++; 857 pow++;
858 } 858 }
859 859
860 ARMOUR_SPEED (armour) = (ARMOUR_SPEED (&armour->arch->clone) * base) / 100; 860 ARMOUR_SPEED (armour) = (ARMOUR_SPEED (armour->arch) * base) / 100;
861 } 861 }
862 else 862 else
863 ARMOUR_SPEED (armour) = (ARMOUR_SPEED (&armour->arch->clone) * (100 + armour->magic * settings.armor_speed_improvement)) / 100; 863 ARMOUR_SPEED (armour) = (ARMOUR_SPEED (armour->arch) * (100 + armour->magic * settings.armor_speed_improvement)) / 100;
864 864
865 if (!settings.armor_weight_linear) 865 if (!settings.armor_weight_linear)
866 { 866 {
867 int base = 100; 867 int base = 100;
868 int pow = 0; 868 int pow = 0;
871 { 871 {
872 base = base - (base * settings.armor_weight_reduction) / 100; 872 base = base - (base * settings.armor_weight_reduction) / 100;
873 pow++; 873 pow++;
874 } 874 }
875 875
876 armour->weight = (armour->arch->clone.weight * base) / 100; 876 armour->weight = (armour->arch->weight * base) / 100;
877 } 877 }
878 else 878 else
879 armour->weight = (armour->arch->clone.weight * (100 - armour->magic * settings.armor_weight_reduction)) / 100; 879 armour->weight = (armour->arch->weight * (100 - armour->magic * settings.armor_weight_reduction)) / 100;
880 880
881 if (armour->weight <= 0) 881 if (armour->weight <= 0)
882 { 882 {
883 LOG (llevInfo, "Warning: enchanted armours can have negative weight\n."); 883 LOG (llevInfo, "Warning: enchanted armours can have negative weight\n.");
884 armour->weight = 1; 884 armour->weight = 1;
885 } 885 }
886 886
887 armour->item_power = get_power_from_ench (armour->arch->clone.item_power + armour->magic); 887 armour->item_power = get_power_from_ench (armour->arch->item_power + armour->magic);
888 888
889 if (op->type == PLAYER) 889 if (op->type == PLAYER)
890 { 890 {
891 esrv_send_item (op, armour); 891 esrv_send_item (op, armour);
892 if (QUERY_FLAG (armour, FLAG_APPLIED)) 892 if (QUERY_FLAG (armour, FLAG_APPLIED))
944 944
945 price_in = cost * item->value; 945 price_in = cost * item->value;
946 } 946 }
947 else 947 else
948 { 948 {
949 if (item->type == PLAYER || CONV_FROM (converter) != item->arch->name || 949 if (item->type == PLAYER || CONV_FROM (converter) != item->arch->archname ||
950 (CONV_NEED (converter) && CONV_NEED (converter) > (uint16) item->nrof)) 950 (CONV_NEED (converter) && CONV_NEED (converter) > (uint16) item->nrof))
951 return 0; 951 return 0;
952 952
953 if (CONV_NEED (converter)) 953 if (CONV_NEED (converter))
954 { 954 {
1006 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n", 1006 LOG (llevDebug, "converter output price higher than input: %s at %s (%d, %d) in value %d, out value %d for %s\n",
1007 &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name); 1007 &converter->name, &converter->map->path, converter->x, converter->y, price_in, item->nrof * item->value, &item->name);
1008 1008
1009 /** 1009 /**
1010 * elmex: we are going to let the game continue, as the mapcreator 1010 * elmex: we are going to let the game continue, as the mapcreator
1011 * propably had something in mind when doing this 1011 * probably had something in mind when doing this
1012 */ 1012 */
1013 } 1013 }
1014 SET_FLAG (item, FLAG_IDENTIFIED);
1014 insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y); 1015 insert_ob_in_map_at (item, converter->map, converter, 0, converter->x, converter->y);
1015 return 1; 1016 return 1;
1016} 1017}
1017 1018
1018/** 1019/**
1245 */ 1246 */
1246static void 1247static void
1247apply_sign (object *op, object *sign, int autoapply) 1248apply_sign (object *op, object *sign, int autoapply)
1248{ 1249{
1249 readable_message_type *msgType; 1250 readable_message_type *msgType;
1250 char newbuf[HUGE_BUF];
1251 1251
1252 if (sign->msg == NULL) 1252 if (sign->msg == NULL)
1253 { 1253 {
1254 new_draw_info (NDI_UNIQUE, 0, op, "Nothing is written on it."); 1254 new_draw_info (NDI_UNIQUE, 0, op, "Nothing is written on it.");
1255 return; 1255 return;
1276 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on) 1276 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ) && !sign->move_on)
1277 { 1277 {
1278 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); 1278 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind.");
1279 return; 1279 return;
1280 } 1280 }
1281
1282 if (op->contr)
1283 if (client *ns = op->contr->ns)
1284 {
1281 msgType = get_readable_message_type (sign); 1285 msgType = get_readable_message_type (sign);
1286
1287 if (ns->can_msg)
1288 ns->send_msg (NDI_NAVY, msgType->msgtype, &sign->msg);
1289 else
1290 {
1291 char newbuf[HUGE_BUF];
1282 snprintf (newbuf, sizeof (newbuf), "%hhu %s", autoapply ? 1 : 0, &sign->msg); 1292 snprintf (newbuf, sizeof (newbuf), "%u %s", autoapply ? 1 : 0, &sign->msg);
1283 draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, newbuf, &sign->msg); 1293 draw_ext_info (NDI_UNIQUE | NDI_NAVY, 0, op, msgType->message_type, msgType->message_subtype, newbuf, &sign->msg);
1294 }
1295 }
1284} 1296}
1285 1297
1286/** 1298/**
1287 * 'victim' moves onto 'trap' 1299 * 'victim' moves onto 'trap'
1288 * 'victim' leaves 'trap' 1300 * 'victim' leaves 'trap'
1311 * proper. This code was causing needless crashes. 1323 * proper. This code was causing needless crashes.
1312 */ 1324 */
1313 if (recursion_depth >= 500) 1325 if (recursion_depth >= 500)
1314 { 1326 {
1315 LOG (llevDebug, "WARNING: move_apply(): aborting recursion " 1327 LOG (llevDebug, "WARNING: move_apply(): aborting recursion "
1316 "[trap arch %s, name %s; victim arch %s, name %s]\n", &trap->arch->name, &trap->name, &victim->arch->name, &victim->name); 1328 "[trap arch %s, name %s; victim arch %s, name %s]\n", &trap->arch->archname, &trap->name, &victim->arch->archname, &victim->name);
1317 return; 1329 return;
1318 } 1330 }
1331
1319 recursion_depth++; 1332 recursion_depth++;
1320 if (trap->head) 1333 if (trap->head)
1321 trap = trap->head; 1334 trap = trap->head;
1322 1335
1323 if (INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator))) 1336 if (INVOKE_OBJECT (MOVE_TRIGGER, trap, ARG_OBJECT (victim), ARG_OBJECT (originator)))
1421 1434
1422 if ((ab->move_type && trap->move_on) || ab->move_type == 0) 1435 if ((ab->move_type && trap->move_on) || ab->move_type == 0)
1423 { 1436 {
1424 if (!sound_was_played) 1437 if (!sound_was_played)
1425 { 1438 {
1426 play_sound_map (trap->map, trap->x, trap->y, SOUND_FALL_HOLE); 1439 trap->play_sound (sound_find ("fall_hole"));
1427 sound_was_played = 1; 1440 sound_was_played = 1;
1428 } 1441 }
1442
1429 new_draw_info (NDI_UNIQUE, 0, ab, "You fall into a trapdoor!"); 1443 new_draw_info (NDI_UNIQUE, 0, ab, "You fall into a trapdoor!");
1430 transfer_ob (ab, (int) EXIT_X (trap), (int) EXIT_Y (trap), 0, ab); 1444 transfer_ob (ab, (int) EXIT_X (trap), (int) EXIT_Y (trap), 0, ab);
1431 } 1445 }
1432 } 1446 }
1433 goto leave; 1447 goto leave;
1466 * Processing will happen if the head runs into the pit 1480 * Processing will happen if the head runs into the pit
1467 */ 1481 */
1468 if (victim->head) 1482 if (victim->head)
1469 goto leave; 1483 goto leave;
1470 1484
1471 play_sound_map (victim->map, victim->x, victim->y, SOUND_FALL_HOLE); 1485 victim->play_sound (sound_find ("fall_hole"));
1472 new_draw_info (NDI_UNIQUE, 0, victim, "You fall through the hole!\n"); 1486 new_draw_info (NDI_UNIQUE, 0, victim, "You fall through the hole!\n");
1473 transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim); 1487 transfer_ob (victim, EXIT_X (trap), EXIT_Y (trap), 1, victim);
1474 goto leave; 1488 goto leave;
1475 1489
1476 case EXIT: 1490 case EXIT:
1518 } 1532 }
1519 goto leave; 1533 goto leave;
1520 1534
1521 default: 1535 default:
1522 LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not " 1536 LOG (llevDebug, "name %s, arch %s, type %d with fly/walk on/off not "
1523 "handled in move_apply()\n", &trap->name, &trap->arch->name, trap->type); 1537 "handled in move_apply()\n", &trap->name, &trap->arch->archname, trap->type);
1524 goto leave; 1538 goto leave;
1525 } 1539 }
1526 1540
1527leave: 1541leave:
1528 recursion_depth--; 1542 recursion_depth--;
1540 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ)) 1554 if (QUERY_FLAG (op, FLAG_BLIND) && !QUERY_FLAG (op, FLAG_WIZ))
1541 { 1555 {
1542 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind."); 1556 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to read while blind.");
1543 return; 1557 return;
1544 } 1558 }
1559
1545 if (tmp->msg == NULL) 1560 if (!tmp->msg)
1546 { 1561 {
1547 new_draw_info_format (NDI_UNIQUE, 0, op, "You open the %s and find it empty.", &tmp->name); 1562 new_draw_info_format (NDI_UNIQUE, 0, op, "You open the %s and find it empty.", &tmp->name);
1548 return; 1563 return;
1549 } 1564 }
1550 1565
1551 /* need a literacy skill to read stuff! */ 1566 /* need a literacy skill to read stuff! */
1552 skill_ob = find_skill_by_name (op, tmp->skill); 1567 skill_ob = find_skill_by_name (op, tmp->skill);
1553 if (!skill_ob) 1568 if (!skill_ob)
1554 { 1569 {
1555 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); 1570 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the skill to read this>");
1556 return; 1571 return;
1557 } 1572 }
1573
1558 lev_diff = tmp->level - (skill_ob->level + 5); 1574 lev_diff = tmp->level - (skill_ob->level + 5);
1559 if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0) 1575 if (!QUERY_FLAG (op, FLAG_WIZ) && lev_diff > 0)
1560 { 1576 {
1561 if (lev_diff < 2) 1577 if (lev_diff < 2)
1562 new_draw_info (NDI_UNIQUE, 0, op, "This book is just barely beyond your comprehension."); 1578 new_draw_info (NDI_UNIQUE, 0, op, "This book is just barely beyond your comprehension.");
1573 return; 1589 return;
1574 } 1590 }
1575 1591
1576 readable_message_type *msgType = get_readable_message_type (tmp); 1592 readable_message_type *msgType = get_readable_message_type (tmp);
1577 1593
1594 if (player *pl = op->contr)
1595 if (client *ns = pl->ns)
1596 if (ns->can_msg)
1597 {
1598 dynbuf_text buf;
1599 buf << long_desc (tmp, op)
1600 << "\n\n"
1601 << tmp->msg
1602 << '\0';
1603 ns->send_msg (NDI_NAVY, msgType->msgtype, buf.linearise ());
1604 }
1605 else
1578 draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op, 1606 draw_ext_info_format (NDI_UNIQUE | NDI_NAVY, 0, op,
1579 msgType->message_type, msgType->message_subtype, 1607 msgType->message_type, msgType->message_subtype,
1580 "You open the %s and start reading.\n%s", (char *)"%s\n%s", 1608 "You open the %s and start reading.\n%s", (char *)"%s\n%s",
1581 long_desc (tmp, op), &tmp->msg); 1609 long_desc (tmp, op), &tmp->msg);
1582 1610
1583 /* gain xp from reading */ 1611 /* gain xp from reading */
1584 if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT)) 1612 if (!QUERY_FLAG (tmp, FLAG_NO_SKILL_IDENT))
1585 { /* only if not read before */ 1613 { /* only if not read before */
1586 int exp_gain = calc_skill_exp (op, tmp, skill_ob); 1614 int exp_gain = calc_skill_exp (op, tmp, skill_ob);
1652 return; 1680 return;
1653 } 1681 }
1654 return; 1682 return;
1655 } 1683 }
1656 1684
1657 play_sound_player_only (op->contr, SOUND_LEARN_SPELL, 0, 0); 1685 op->contr->play_sound (sound_find ("learn_spell"));
1686
1658 tmp = spell->clone (); 1687 tmp = spell->clone ();
1659 insert_ob_in_ob (tmp, op); 1688 insert_ob_in_ob (tmp, op);
1660 1689
1661 if (special_prayer) 1690 if (special_prayer)
1662 SET_FLAG (tmp, FLAG_STARTEQUIP); 1691 SET_FLAG (tmp, FLAG_STARTEQUIP);
1707 1736
1708 /* artifact_spellbooks have 'slaying' field point to a spell name, 1737 /* artifact_spellbooks have 'slaying' field point to a spell name,
1709 * instead of having their spell stored in stats.sp. These are 1738 * instead of having their spell stored in stats.sp. These are
1710 * legacy spellbooks 1739 * legacy spellbooks
1711 */ 1740 */
1712
1713 if (tmp->slaying != NULL) 1741 if (tmp->slaying)
1714 { 1742 {
1715 spell = arch_to_object (find_archetype_by_object_name (tmp->slaying)); 1743 spell = arch_to_object (find_archetype_by_object_name (tmp->slaying));
1716 if (!spell) 1744 if (!spell)
1717 { 1745 {
1718 new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying); 1746 new_draw_info_format (NDI_UNIQUE, 0, op, "The book's formula for %s is incomplete", &tmp->slaying);
1719 return; 1747 return;
1720 } 1748 }
1721 else 1749 else
1722 insert_ob_in_ob (spell, tmp); 1750 insert_ob_in_ob (spell, tmp);
1751
1723 tmp->slaying = NULL; 1752 tmp->slaying = 0;
1724 } 1753 }
1725 1754
1726 skop = find_skill_by_name (op, tmp->skill); 1755 skop = find_skill_by_name (op, tmp->skill);
1727 1756
1728 /* need a literacy skill to learn spells. Also, having a literacy level 1757 /* need a literacy skill to learn spells. Also, having a literacy level
1729 * lower than the spell will make learning the spell more difficult */ 1758 * lower than the spell will make learning the spell more difficult */
1730 if (!skop) 1759 if (!skop)
1731 { 1760 {
1732 new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails."); 1761 new_draw_info (NDI_UNIQUE, 0, op, "You can't read! Your attempt fails. H<You lack the literacy skill.>");
1733 return; 1762 return;
1734 } 1763 }
1735 1764
1736 spell = tmp->inv; 1765 spell = tmp->inv;
1737 1766
1738 if (!spell) 1767 if (!spell)
1739 { 1768 {
1740 LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name); 1769 LOG (llevError, "apply_spellbook: Book %s has no spell in it!\n", &tmp->name);
1741 new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense."); 1770 new_draw_info (NDI_UNIQUE, 0, op, "The spellbook symbols make no sense. This is a bug, please report!");
1742 return; 1771 return;
1743 } 1772 }
1744 1773
1745 if (skop->level < int (sqrtf (spell->level) * 1.5f)) 1774 if (skop->level < int (sqrtf (spell->level) * 1.5f))
1746 { 1775 {
1747 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. [Your literacy level is too low]"); 1776 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<Your literacy level is too low.>");
1748 return; 1777 return;
1749 } 1778 }
1750 1779
1751 new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name); 1780 new_draw_info_format (NDI_UNIQUE, 0, op, "The spellbook contains the %s level spell %s.", get_levelnumber (spell->level), &spell->name);
1752 1781
1765 * if the player doesn't know the spell, doesn't make a lot of sense that 1794 * if the player doesn't know the spell, doesn't make a lot of sense that
1766 * they would have a special prayer mark. 1795 * they would have a special prayer mark.
1767 */ 1796 */
1768 if (check_spell_known (op, spell->name)) 1797 if (check_spell_known (op, spell->name))
1769 { 1798 {
1770 new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell.\n"); 1799 new_draw_info (NDI_UNIQUE, 0, op, "You already know that spell. H<It makes no sense to learn spells twice, and would only waste the spellbook.>\n");
1771 return; 1800 return;
1772 } 1801 }
1773 1802
1774 if (spell->skill) 1803 if (spell->skill)
1775 { 1804 {
1816 if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP)) 1845 if (!QUERY_FLAG (tmp, FLAG_STARTEQUIP))
1817 change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0); 1846 change_exp (op, calc_skill_exp (op, tmp, skop), skop->skill, 0);
1818 } 1847 }
1819 else 1848 else
1820 { 1849 {
1821 play_sound_player_only (op->contr, SOUND_FUMBLE_SPELL, 0, 0); 1850 op->contr->play_sound (sound_find ("fumble_spell"));
1822 new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell.\n"); 1851 new_draw_info (NDI_UNIQUE, 0, op, "You fail to learn the spell. H<Wis (priests) or Int (wizards) governs the chance of learning a prayer or spell.>\n");
1823 } 1852 }
1824 1853
1825 decrease_ob (tmp); 1854 decrease_ob (tmp);
1826} 1855}
1827 1856
1839 return; 1868 return;
1840 } 1869 }
1841 1870
1842 if (!tmp->inv || tmp->inv->type != SPELL) 1871 if (!tmp->inv || tmp->inv->type != SPELL)
1843 { 1872 {
1844 new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense!"); 1873 new_draw_info (NDI_UNIQUE, 0, op, "The scroll just doesn't make sense! H<...and never will make sense.>");
1845 return; 1874 return;
1846 } 1875 }
1847 1876
1848 if (op->type == PLAYER) 1877 if (op->type == PLAYER)
1849 { 1878 {
1855 */ 1884 */
1856 skop = find_skill_by_name (op, skill_names[SK_LITERACY]); 1885 skop = find_skill_by_name (op, skill_names[SK_LITERACY]);
1857 1886
1858 if (!skop) 1887 if (!skop)
1859 { 1888 {
1860 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols."); 1889 new_draw_info (NDI_UNIQUE, 0, op, "You are unable to decipher the strange symbols. H<You lack the literacy skill.>");
1861 return; 1890 return;
1862 } 1891 }
1863 1892
1864 if ((exp_gain = calc_skill_exp (op, tmp, skop))) 1893 if ((exp_gain = calc_skill_exp (op, tmp, skop)))
1865 change_exp (op, exp_gain, skop->skill, 0); 1894 change_exp (op, exp_gain, skop->skill, 0);
1986 /* special food hack -b.t. */ 2015 /* special food hack -b.t. */
1987 if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED)) 2016 if (tmp->title || QUERY_FLAG (tmp, FLAG_CURSED))
1988 eat_special_food (op, tmp); 2017 eat_special_food (op, tmp);
1989 } 2018 }
1990 } 2019 }
2020
1991 handle_apply_yield (tmp); 2021 handle_apply_yield (tmp);
1992 decrease_ob (tmp); 2022 decrease_ob (tmp);
1993} 2023}
1994 2024
1995/** 2025/**
2022 if (meal->type != FLESH || !is_dragon_pl (op)) 2052 if (meal->type != FLESH || !is_dragon_pl (op))
2023 return 0; 2053 return 0;
2024 2054
2025 /* now grab the 'dragon_skin'- and 'dragon_ability'-forces 2055 /* now grab the 'dragon_skin'- and 'dragon_ability'-forces
2026 from the player's inventory */ 2056 from the player's inventory */
2027 shstr_cmp dragon_ability_force ("dragon_ability_force");
2028 shstr_cmp dragon_skin_force ("dragon_skin_force");
2029
2030 for (tmp = op->inv; tmp; tmp = tmp->below) 2057 for (tmp = op->inv; tmp; tmp = tmp->below)
2031 if (tmp->type == FORCE) 2058 if (tmp->type == FORCE)
2032 if (tmp->arch->name == dragon_skin_force) 2059 if (tmp->arch->archname == shstr_dragon_skin_force)
2033 skin = tmp; 2060 skin = tmp;
2034 else if (tmp->arch->name == dragon_ability_force) 2061 else if (tmp->arch->archname == shstr_dragon_ability_force)
2035 abil = tmp; 2062 abil = tmp;
2036 2063
2037 /* if either skin or ability are missing, this is an old player 2064 /* if either skin or ability are missing, this is an old player
2038 which is not to be considered a dragon -> bail out */ 2065 which is not to be considered a dragon -> bail out */
2039 if (skin == NULL || abil == NULL) 2066 if (skin == NULL || abil == NULL)
2160static void 2187static void
2161apply_armour_improver (object *op, object *tmp) 2188apply_armour_improver (object *op, object *tmp)
2162{ 2189{
2163 object *armor; 2190 object *armor;
2164 2191
2165 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_MAGIC)) 2192 if (!QUERY_FLAG (op, FLAG_WIZCAST) && (get_map_flags (op->map, 0, op->x, op->y, 0, 0) & P_NO_MAGIC))
2166 { 2193 {
2167 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll."); 2194 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the scroll. H<The area prevents magic effects.>");
2168 return; 2195 return;
2169 } 2196 }
2170 2197
2171 armor = find_marked_object (op); 2198 armor = find_marked_object (op);
2172 2199
2173 if (!armor) 2200 if (!armor)
2174 { 2201 {
2175 new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object."); 2202 new_draw_info (NDI_UNIQUE, 0, op, "You need to mark an armor object. Use the right mouse button popup or the mark command to do this.");
2176 return; 2203 return;
2177 } 2204 }
2178 2205
2179 if (armor->type != ARMOUR 2206 if (armor->type != ARMOUR
2180 && armor->type != CLOAK 2207 && armor->type != CLOAK
2191extern void 2218extern void
2192apply_poison (object *op, object *tmp) 2219apply_poison (object *op, object *tmp)
2193{ 2220{
2194 if (op->type == PLAYER) 2221 if (op->type == PLAYER)
2195 { 2222 {
2196 play_sound_player_only (op->contr, SOUND_DRINK_POISON, 0, 0); 2223 op->contr->play_sound (sound_find ("drink_poison"));
2197 new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!"); 2224 new_draw_info (NDI_UNIQUE, 0, op, "Yech! That tasted poisonous!");
2198 strcpy (op->contr->killer, "poisonous booze"); 2225 strcpy (op->contr->killer, "poisonous booze");
2199 } 2226 }
2227
2200 if (tmp->stats.hp > 0) 2228 if (tmp->stats.hp > 0)
2201 { 2229 {
2202 LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp); 2230 LOG (llevDebug, "Trying to poison player/monster for %d hp\n", tmp->stats.hp);
2203 hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1); 2231 hit_player (op, tmp->stats.hp, tmp, AT_POISON, 1);
2204 } 2232 }
2233
2205 op->stats.food -= op->stats.food / 4; 2234 op->stats.food -= op->stats.food / 4;
2206 handle_apply_yield (tmp); 2235 handle_apply_yield (tmp);
2207 decrease_ob (tmp); 2236 decrease_ob (tmp);
2208} 2237}
2209 2238
2319 2348
2320 if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED)) 2349 if (QUERY_FLAG (tmp, FLAG_UNPAID) && !QUERY_FLAG (tmp, FLAG_APPLIED))
2321 { 2350 {
2322 if (op->type == PLAYER) 2351 if (op->type == PLAYER)
2323 { 2352 {
2324 new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first."); 2353 new_draw_info (NDI_UNIQUE, 0, op, "You should pay for it first. H<You cannot use items marked as unpaid.>");
2325 return 1; 2354 return 1;
2326 } 2355 }
2327 else 2356 else
2328 return 0; /* monsters just skip unpaid items */ 2357 return 0; /* monsters just skip unpaid items */
2329 } 2358 }
2333 2362
2334 switch (tmp->type) 2363 switch (tmp->type)
2335 { 2364 {
2336 case CF_HANDLE: 2365 case CF_HANDLE:
2337 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); 2366 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle.");
2338 play_sound_map (op->map, op->x, op->y, SOUND_TURN_HANDLE); 2367 op->play_sound (sound_find ("turn_handle"));
2339 tmp->value = tmp->value ? 0 : 1; 2368 tmp->value = tmp->value ? 0 : 1;
2340 SET_ANIMATION (tmp, tmp->value); 2369 SET_ANIMATION (tmp, tmp->value);
2341 update_object (tmp, UP_OBJ_FACE); 2370 update_object (tmp, UP_OBJ_FACE);
2342 push_button (tmp); 2371 push_button (tmp);
2343 return 1; 2372 return 1;
2344 2373
2345 case TRIGGER: 2374 case TRIGGER:
2346 if (check_trigger (tmp, op)) 2375 if (check_trigger (tmp, op))
2347 { 2376 {
2348 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle."); 2377 new_draw_info (NDI_UNIQUE, 0, op, "You turn the handle.");
2349 play_sound_map (tmp->map, tmp->x, tmp->y, SOUND_TURN_HANDLE); 2378 op->play_sound (sound_find ("turn_handle"));
2350 } 2379 }
2351 else 2380 else
2352 new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move."); 2381 new_draw_info (NDI_UNIQUE, 0, op, "The handle doesn't move.");
2353 2382
2354 return 1; 2383 return 1;
2487 2516
2488 get_tod (&tod); 2517 get_tod (&tod);
2489 sprintf (buf, "It is %d minute%s past %d o'clock %s", 2518 sprintf (buf, "It is %d minute%s past %d o'clock %s",
2490 tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"), 2519 tod.minute + 1, ((tod.minute + 1 < 2) ? "" : "s"),
2491 ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am")); 2520 ((tod.hour % 14 == 0) ? 14 : ((tod.hour) % 14)), ((tod.hour >= 14) ? "pm" : "am"));
2492 play_sound_player_only (op->contr, SOUND_CLOCK, 0, 0); 2521 op->play_sound (sound_find ("sound_clock"));
2493 new_draw_info (NDI_UNIQUE, 0, op, buf); 2522 new_draw_info (NDI_UNIQUE, 0, op, buf);
2494 return 1; 2523 return 1;
2495 } 2524 }
2496 else 2525 else
2497 return 0; 2526 return 0;
2537int 2566int
2538player_apply (object *pl, object *op, int aflag, int quiet) 2567player_apply (object *pl, object *op, int aflag, int quiet)
2539{ 2568{
2540 int tmp; 2569 int tmp;
2541 2570
2542 if (op->env == NULL && (pl->move_type & MOVE_FLYING)) 2571 if (op->env && (pl->move_type & MOVE_FLYING))
2543 { 2572 {
2544 /* player is flying and applying object not in inventory */ 2573 /* player is flying and applying object not in inventory */
2545 if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING)) 2574 if (!QUERY_FLAG (pl, FLAG_WIZ) && !(op->move_type & MOVE_FLYING))
2546 { 2575 {
2547 new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high " "above the ground!"); 2576 new_draw_info (NDI_UNIQUE, 0, pl, "But you are floating high above the ground! H<You have to stop levitating first, if you can.>");
2548 return 0; 2577 return 0;
2549 } 2578 }
2550 } 2579 }
2551 2580
2552 pl->contr->last_used = op; 2581 pl->contr->last_used = op;
2557 if (tmp == 0) 2586 if (tmp == 0)
2558 new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op)); 2587 new_draw_info_format (NDI_UNIQUE, 0, pl, "I don't know how to apply the %s.", query_name (op));
2559 else if (tmp == 2) 2588 else if (tmp == 2)
2560 new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n"); 2589 new_draw_info_format (NDI_UNIQUE, 0, pl, "You must get it first!\n");
2561 } 2590 }
2591
2562 return tmp; 2592 return tmp;
2563} 2593}
2564 2594
2565/** 2595/**
2566 * player_apply_below attempts to apply the object 'below' the player. 2596 * player_apply_below attempts to apply the object 'below' the player.
2806 * Returns 0 on success, returns 1 if there is some problem. 2836 * Returns 0 on success, returns 1 if there is some problem.
2807 * if aflags is AP_PRINT, we instead print out waht to unapply 2837 * if aflags is AP_PRINT, we instead print out waht to unapply
2808 * instead of doing it. This is a lot less code than having 2838 * instead of doing it. This is a lot less code than having
2809 * another function that does just that. 2839 * another function that does just that.
2810 */ 2840 */
2841
2842#define CANNOT_REMOVE_CURSED \
2843 "H<You cannot remove cursed or damned items, you first have to remove the curse. " \
2844 "Praying over an altar, scrolls of remove curse/damnation, " \
2845 "priests or even other players might help.>"
2846
2811int 2847int
2812unapply_for_ob (object *who, object *op, int aflags) 2848unapply_for_ob (object *who, object *op, int aflags)
2813{ 2849{
2814 if (op->is_range ()) 2850 if (op->is_range ())
2815 for (object *tmp = who->inv; tmp; tmp = tmp->below) 2851 for (object *tmp = who->inv; tmp; tmp = tmp->below)
2825 { 2861 {
2826 /* In this case, we want to try and remove a cursed item. 2862 /* In this case, we want to try and remove a cursed item.
2827 * While we know it won't work, we want unapply_special to 2863 * While we know it won't work, we want unapply_special to
2828 * at least generate the message. 2864 * at least generate the message.
2829 */ 2865 */
2830 new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove the %s.", query_name (tmp)); 2866 new_draw_info_format (NDI_UNIQUE, 0, who,
2867 "No matter how hard you try, you just can't remove the %s." CANNOT_REMOVE_CURSED,
2868 query_name (tmp));
2831 return 1; 2869 return 1;
2832 } 2870 }
2833 2871
2834 for (int i = 0; i < NUM_BODY_LOCATIONS; i++) 2872 for (int i = 0; i < NUM_BODY_LOCATIONS; i++)
2835 { 2873 {
2869 /* Cursed item that we can't unequip - tell the player. 2907 /* Cursed item that we can't unequip - tell the player.
2870 * Note this could be annoying if this is just one of a few, 2908 * Note this could be annoying if this is just one of a few,
2871 * so it may not be critical (eg, putting on a ring and you have 2909 * so it may not be critical (eg, putting on a ring and you have
2872 * one cursed ring.) 2910 * one cursed ring.)
2873 */ 2911 */
2874 new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off", query_name (tmp)); 2912 new_draw_info_format (NDI_UNIQUE, 0, who, "The %s just won't come off." CANNOT_REMOVE_CURSED, query_name (tmp));
2875 } 2913 }
2876 2914
2877 last = tmp->below; 2915 last = tmp->below;
2878 } 2916 }
2879 /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the 2917 /* if we got here, this slot is freed up - otherwise, if it wasn't freed up, the
3032 * 3070 *
3033 * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE) 3071 * Usage example: apply_special (who, op, AP_UNAPPLY | AP_IGNORE_CURSE)
3034 * 3072 *
3035 * apply_special() doesn't check for unpaid items. 3073 * apply_special() doesn't check for unpaid items.
3036 */ 3074 */
3075
3076#define LACK_ITEM_POWER \
3077 " H<You lack enough unused item power to use this weapon, see the skills command.>"
3078
3037int 3079int
3038apply_special (object *who, object *op, int aflags) 3080apply_special (object *who, object *op, int aflags)
3039{ 3081{
3040 int basic_flag = aflags & AP_BASIC_FLAGS; 3082 int basic_flag = aflags & AP_BASIC_FLAGS;
3041 object *tmp, *tmp2, *skop = NULL; 3083 object *tmp, *tmp2, *skop = NULL;
3056 if (basic_flag == AP_APPLY) 3098 if (basic_flag == AP_APPLY)
3057 return 0; 3099 return 0;
3058 3100
3059 if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))) 3101 if (!(aflags & AP_IGNORE_CURSE) && (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)))
3060 { 3102 {
3061 new_draw_info_format (NDI_UNIQUE, 0, who, "No matter how hard you try, you just can't remove %s.", query_name (op)); 3103 new_draw_info_format (NDI_UNIQUE, 0, who,
3104 "No matter how hard you try, you just can't remove %s." CANNOT_REMOVE_CURSED,
3105 query_name (op));
3062 return 1; 3106 return 1;
3063 } 3107 }
3064 3108
3065 return unapply_special (who, op, aflags); 3109 return unapply_special (who, op, aflags);
3066 } 3110 }
3082 /* Can't just apply this object. Lets see what not and what to do */ 3126 /* Can't just apply this object. Lets see what not and what to do */
3083 if (int i = can_apply_object (who, op)) 3127 if (int i = can_apply_object (who, op))
3084 { 3128 {
3085 if (i & CAN_APPLY_NEVER) 3129 if (i & CAN_APPLY_NEVER)
3086 { 3130 {
3087 new_draw_info_format (NDI_UNIQUE, 0, who, "You don't have the body to use a %s\n", query_name (op)); 3131 new_draw_info_format (NDI_UNIQUE, 0, who,
3132 "You don't have the body to use a %s. H<You can never apply this item.>",
3133 query_name (op));
3088 return 1; 3134 return 1;
3089 } 3135 }
3090 else if (i & CAN_APPLY_RESTRICTION) 3136 else if (i & CAN_APPLY_RESTRICTION)
3091 { 3137 {
3092 new_draw_info_format (NDI_UNIQUE, 0, who, "You have a prohibition against using a %s\n", query_name (op)); 3138 new_draw_info_format (NDI_UNIQUE, 0, who,
3139 "You have a prohibition against using a %s. "
3140 "H<Your belief, profession or class prevents you from applying this item.>",
3141 query_name (op));
3093 return 1; 3142 return 1;
3094 } 3143 }
3095 3144
3096 if (who->type != PLAYER) 3145 if (who->type != PLAYER)
3097 { 3146 {
3132 if (who->type == PLAYER 3181 if (who->type == PLAYER
3133 && op->item_power 3182 && op->item_power
3134 && op->item_power + who->contr->item_power > settings.item_power_factor * who->level) 3183 && op->item_power + who->contr->item_power > settings.item_power_factor * who->level)
3135 { 3184 {
3136 new_draw_info (NDI_UNIQUE, 0, who, 3185 new_draw_info (NDI_UNIQUE, 0, who,
3137 "Equipping that combined with other items would consume your soul! " 3186 "Equipping that combined with other items would consume your soul!" LACK_ITEM_POWER);
3138 "[use the skills command to check your available item power]");
3139 return 1; 3187 return 1;
3140 } 3188 }
3141 3189
3142 /* Ok. We are now at the state where we can apply the new object. 3190 /* Ok. We are now at the state where we can apply the new object.
3143 * Note that we don't have the checks for can_use_... 3191 * Note that we don't have the checks for can_use_...
3155 { 3203 {
3156 case WEAPON: 3204 case WEAPON:
3157 if (!check_weapon_power (who, op->last_eat)) 3205 if (!check_weapon_power (who, op->last_eat))
3158 { 3206 {
3159 new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. " 3207 new_draw_info (NDI_UNIQUE, 0, who, "This weapon is too powerful for you to use. "
3160 "It would consume your soul!."); 3208 "It would consume your soul!." LACK_ITEM_POWER);
3161 3209
3162 if (tmp) 3210 if (tmp)
3163 insert_ob_in_ob (tmp, who); 3211 insert_ob_in_ob (tmp, who);
3164 3212
3165 return 1; 3213 return 1;
3169 // i.e. "R" can use Ragnarok's sword. 3217 // i.e. "R" can use Ragnarok's sword.
3170 if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) 3218 if (op->level && (strncmp (op->name, who->name, strlen (who->name))))
3171 { 3219 {
3172 /* if the weapon does not have the name as the character, can't use it. */ 3220 /* if the weapon does not have the name as the character, can't use it. */
3173 /* (Ragnarok's sword attempted to be used by Foo: won't work) */ 3221 /* (Ragnarok's sword attempted to be used by Foo: won't work) */
3174 new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); 3222 new_draw_info (NDI_UNIQUE, 0, who,
3223 "The weapon does not recognize you as its owner. "
3224 "H<Its name indicates that it belongs to somebody else.>");
3175 3225
3176 if (tmp) 3226 if (tmp)
3177 insert_ob_in_ob (tmp, who); 3227 insert_ob_in_ob (tmp, who);
3178 3228
3179 return 1; 3229 return 1;
3213 break; 3263 break;
3214 3264
3215 case LAMP: 3265 case LAMP:
3216 if (op->stats.food < 1) 3266 if (op->stats.food < 1)
3217 { 3267 {
3218 new_draw_info_format (NDI_UNIQUE, 0, who, "Your %s is out of fuel!", &op->name); 3268 new_draw_info_format (NDI_UNIQUE, 0, who,
3269 "Your %s is out of fuel! "
3270 "H<Lamps and similar items need fuel. They cannot be refilled.>", &op->name);
3219 return 1; 3271 return 1;
3220 } 3272 }
3221 3273
3222 new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name); 3274 new_draw_info_format (NDI_UNIQUE, 0, who, "You turn on your %s.", &op->name);
3223 tmp2 = arch_to_object (op->other_arch); 3275 tmp2 = arch_to_object (op->other_arch);
3246 who->update_stats (); 3298 who->update_stats ();
3247 3299
3248 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 3300 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
3249 if (who->type == PLAYER) 3301 if (who->type == PLAYER)
3250 { 3302 {
3251 new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); 3303 new_draw_info (NDI_UNIQUE, 0, who,
3304 "Oops, it feels deadly cold! "
3305 "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>");
3252 SET_FLAG (tmp2, FLAG_KNOWN_CURSED); 3306 SET_FLAG (tmp2, FLAG_KNOWN_CURSED);
3253 } 3307 }
3254 3308
3255 if (who->type == PLAYER) 3309 if (who->type == PLAYER)
3256 esrv_send_item (who, tmp2); 3310 esrv_send_item (who, tmp2);
3284 who->change_weapon (pl->combat_ob = item); 3338 who->change_weapon (pl->combat_ob = item);
3285 goto found_weapon; 3339 goto found_weapon;
3286 } 3340 }
3287 } 3341 }
3288 3342
3289 new_draw_info_format (NDI_UNIQUE, 0, who, "You need to apply a '%s' melee weapon before readying this skill", &op->skill); 3343 new_draw_info_format (NDI_UNIQUE, 0, who,
3344 "You need to apply a '%s' melee weapon before readying this skill. "
3345 "H<Some skills need an item, in this case a melee weapon, to function.>",
3346 &op->skill);
3290 return 1; 3347 return 1;
3291 3348
3292 found_weapon:; 3349 found_weapon:;
3293 } 3350 }
3294 else 3351 else
3304 //TODO: bows should/must all have skill missile weapon right now 3361 //TODO: bows should/must all have skill missile weapon right now
3305 who->change_weapon (pl->ranged_ob = item); 3362 who->change_weapon (pl->ranged_ob = item);
3306 goto found_bow; 3363 goto found_bow;
3307 } 3364 }
3308 3365
3366 new_draw_info (NDI_UNIQUE, 0, who,
3309 new_draw_info (NDI_UNIQUE, 0, who, "You need to apply a missile weapon before readying this skill"); 3367 "You need to apply a missile weapon before readying this skill. "
3368 "H<Some skills need an item, in this case a missile weapon, to function.>");
3310 return 1; 3369 return 1;
3311 3370
3312 found_bow:; 3371 found_bow:;
3313 } 3372 }
3314 else 3373 else
3334 break; 3393 break;
3335 3394
3336 case BOW: 3395 case BOW:
3337 if (!check_weapon_power (who, op->last_eat)) 3396 if (!check_weapon_power (who, op->last_eat))
3338 { 3397 {
3339 new_draw_info (NDI_UNIQUE, 0, who, "That weapon is too powerful for you to use."); 3398 new_draw_info (NDI_UNIQUE, 0, who,
3340 new_draw_info (NDI_UNIQUE, 0, who, "It would consume your soul!."); 3399 "That weapon is too powerful for you to use. It would consume your soul!" LACK_ITEM_POWER);
3341 3400
3342 if (tmp) 3401 if (tmp)
3343 insert_ob_in_ob (tmp, who); 3402 insert_ob_in_ob (tmp, who);
3344 3403
3345 return 1; 3404 return 1;
3346 } 3405 }
3347 3406
3348 if (op->level && (strncmp (op->name, who->name, strlen (who->name)))) 3407 if (op->level && (strncmp (op->name, who->name, strlen (who->name))))
3349 { 3408 {
3350 new_draw_info (NDI_UNIQUE, 0, who, "The weapon does not recognize you as its owner."); 3409 new_draw_info (NDI_UNIQUE, 0, who,
3410 "The weapon does not recognize you as its owner. "
3411 "H<Its name indicates that it belongs to somebody else.>");
3351 if (tmp) 3412 if (tmp)
3352 insert_ob_in_ob (tmp, who); 3413 insert_ob_in_ob (tmp, who);
3353 3414
3354 return 1; 3415 return 1;
3355 } 3416 }
3423 */ 3484 */
3424 if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD) 3485 if (who->type == PLAYER && op->type != WAND && op->type != HORN && op->type != ROD)
3425 SET_FLAG (op, FLAG_BEEN_APPLIED); 3486 SET_FLAG (op, FLAG_BEEN_APPLIED);
3426 3487
3427 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED)) 3488 if (QUERY_FLAG (op, FLAG_CURSED) || QUERY_FLAG (op, FLAG_DAMNED))
3428 {
3429 if (who->type == PLAYER) 3489 if (who->type == PLAYER)
3430 { 3490 {
3431 new_draw_info (NDI_UNIQUE, 0, who, "Oops, it feels deadly cold!"); 3491 new_draw_info (NDI_UNIQUE, 0, who,
3492 "Oops, it feels deadly cold! "
3493 "H<Maybe it wasn't such a bright idea to apply this cursed/damned item.>");
3432 SET_FLAG (op, FLAG_KNOWN_CURSED); 3494 SET_FLAG (op, FLAG_KNOWN_CURSED);
3433 } 3495 }
3434 }
3435 3496
3436 if (who->type == PLAYER) 3497 if (who->type == PLAYER)
3437 { 3498 {
3438 /* if multiple objects were applied, update both slots */ 3499 /* if multiple objects were applied, update both slots */
3439 if (tmp) 3500 if (tmp)
3448int 3509int
3449monster_apply_special (object *who, object *op, int aflags) 3510monster_apply_special (object *who, object *op, int aflags)
3450{ 3511{
3451 if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED)) 3512 if (QUERY_FLAG (op, FLAG_UNPAID) && !QUERY_FLAG (op, FLAG_APPLIED))
3452 return 1; 3513 return 1;
3514
3453 return apply_special (who, op, aflags); 3515 return apply_special (who, op, aflags);
3454} 3516}
3455 3517
3456/** 3518/**
3457 * Map was just loaded, handle op's initialisation. 3519 * Map was just loaded, handle op's initialisation.
3783 3845
3784 if (failure <= -1 && failure > -15) 3846 if (failure <= -1 && failure > -15)
3785 { /* wonder */ 3847 { /* wonder */
3786 object *tmp; 3848 object *tmp;
3787 3849
3788 new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!."); 3850 new_draw_info (NDI_UNIQUE, 0, op, "Your spell warps!");
3789 tmp = get_archetype (SPELL_WONDER); 3851 tmp = get_archetype (SPELL_WONDER);
3790 cast_wonder (op, op, 0, tmp); 3852 cast_wonder (op, op, 0, tmp);
3791 tmp->destroy (); 3853 tmp->destroy ();
3792 } 3854 }
3793 else if (failure <= -15 && failure > -35) 3855 else if (failure <= -15 && failure > -35)
3846 */ 3908 */
3847 int i, j; 3909 int i, j;
3848 3910
3849 for (i = 0; i < NUM_STATS; i++) 3911 for (i = 0; i < NUM_STATS; i++)
3850 { 3912 {
3851 int race_bonus = pl->arch->clone.stats.stat (i); 3913 int race_bonus = pl->arch->stats.stat (i);
3852 sint8 stat = stats->stat (i) + ns->stat (i); 3914 sint8 stat = stats->stat (i) + ns->stat (i);
3853 3915
3854 if (stat > 20 + race_bonus) 3916 if (stat > 20 + race_bonus)
3855 { 3917 {
3856 excess_stat++; 3918 excess_stat++;
3866 3928
3867 if (i == CHA) 3929 if (i == CHA)
3868 continue; /* exclude cha from this */ 3930 continue; /* exclude cha from this */
3869 3931
3870 int stat = stats->stat (i); 3932 int stat = stats->stat (i);
3871 int race_bonus = pl->arch->clone.stats.stat (i); 3933 int race_bonus = pl->arch->stats.stat (i);
3872 if (stat < 20 + race_bonus) 3934 if (stat < 20 + race_bonus)
3873 { 3935 {
3874 change_attr_value (stats, i, 1); 3936 change_attr_value (stats, i, 1);
3875 excess_stat--; 3937 excess_stat--;
3876 } 3938 }
3933 char got[MAX_BUF]; 3995 char got[MAX_BUF];
3934 int len; 3996 int len;
3935 3997
3936 if (!pl || !transformer) 3998 if (!pl || !transformer)
3937 return; 3999 return;
4000
3938 marked = find_marked_object (pl); 4001 marked = find_marked_object (pl);
4002
3939 if (!marked) 4003 if (!marked)
3940 { 4004 {
3941 new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer)); 4005 new_draw_info_format (NDI_UNIQUE, 0, pl, "Use the %s with what item?", query_name (transformer));
3942 return; 4006 return;
3943 } 4007 }
4008
3944 if (!marked->slaying) 4009 if (!marked->slaying)
3945 { 4010 {
3946 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); 4011 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked));
3947 return; 4012 return;
3948 } 4013 }
4014
3949 /* check whether they are compatible or not */ 4015 /* check whether they are compatible or not */
3950 find = strstr (marked->slaying, transformer->arch->name); 4016 find = strstr (marked->slaying, transformer->arch->archname);
3951 if (!find || (*(find + strlen (transformer->arch->name)) != ':')) 4017 if (!find || (*(find + strlen (transformer->arch->archname)) != ':'))
3952 { 4018 {
3953 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked)); 4019 new_draw_info_format (NDI_UNIQUE, 0, pl, "You can't use the %s with your %s!", query_name (transformer), query_name (marked));
3954 return; 4020 return;
3955 } 4021 }
4022
3956 find += strlen (transformer->arch->name) + 1; 4023 find += strlen (transformer->arch->archname) + 1;
3957 /* Item can be used, now find how many and what it yields */ 4024 /* Item can be used, now find how many and what it yields */
3958 if (isdigit (*(find))) 4025 if (isdigit (*(find)))
3959 { 4026 {
3960 yield = atoi (find); 4027 yield = atoi (find);
3961 if (yield < 1) 4028 if (yield < 1)
3969 4036
3970 while (isdigit (*find)) 4037 while (isdigit (*find))
3971 find++; 4038 find++;
3972 while (*find == ' ') 4039 while (*find == ' ')
3973 find++; 4040 find++;
4041
3974 memset (got, 0, MAX_BUF); 4042 memset (got, 0, MAX_BUF);
4043
3975 if ((separator = strchr (find, ';')) != NULL) 4044 if ((separator = strchr (find, ';')) != NULL)
3976 {
3977 len = separator - find; 4045 len = separator - find;
3978 }
3979 else 4046 else
3980 {
3981 len = strlen (find); 4047 len = strlen (find);
3982 } 4048
3983 if (len > MAX_BUF - 1) 4049 if (len > MAX_BUF - 1)
3984 len = MAX_BUF - 1; 4050 len = MAX_BUF - 1;
4051
3985 strcpy (got, find); 4052 strcpy (got, find);
3986 got[len] = '\0'; 4053 got[len] = '\0';
3987 4054
3988 /* Now create new item, remove used ones when required. */ 4055 /* Now create new item, remove used ones when required. */
3989 new_item = get_archetype (got); 4056 new_item = get_archetype (got);
3997 new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0)); 4064 new_draw_info_format (NDI_UNIQUE, 0, pl, "You %s the %s.", &transformer->slaying, query_base_name (marked, 0));
3998 insert_ob_in_ob (new_item, pl); 4065 insert_ob_in_ob (new_item, pl);
3999 esrv_send_inventory (pl, pl); 4066 esrv_send_inventory (pl, pl);
4000 /* Eat up one item */ 4067 /* Eat up one item */
4001 decrease_ob_nr (marked, 1); 4068 decrease_ob_nr (marked, 1);
4069
4002 /* Eat one transformer if needed */ 4070 /* Eat one transformer if needed */
4003 if (transformer->stats.food) 4071 if (transformer->stats.food)
4004 if (--transformer->stats.food == 0) 4072 if (--transformer->stats.food == 0)
4005 decrease_ob_nr (transformer, 1); 4073 decrease_ob_nr (transformer, 1);
4006} 4074}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines