1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425
|
#include "AppHdr.h"
#include "player-equip.h"
#include "areas.h"
#include "artefact.h"
#include "delay.h"
#include "describe.h"
#include "food.h"
#include "goditem.h"
#include "godpassive.h"
#include "hints.h"
#include "item_use.h"
#include "itemname.h"
#include "itemprop.h"
#include "items.h"
#include "misc.h"
#include "notes.h"
#include "options.h"
#include "player.h"
#include "player-stats.h"
#include "religion.h"
#include "shopping.h"
#include "skills2.h"
#include "spl-cast.h"
#include "spl-mis.h"
#include "state.h"
#include "stuff.h"
#include "transform.h"
#include "xom.h"
#include <cmath>
static void _equip_effect(equipment_type slot, int item_slot, bool unmeld, bool msg);
static void _unequip_effect(equipment_type slot, int item_slot, bool msg);
// Fill an empty equipment slot.
void equip_item(equipment_type slot, int item_slot, bool msg)
{
ASSERT(slot > EQ_NONE && slot < NUM_EQUIP);
ASSERT(you.equip[slot] == -1);
ASSERT(!you.melded[slot]);
you.equip[slot] = item_slot;
_equip_effect(slot, item_slot, false, msg);
}
// Clear an equipment slot (possibly melded).
bool unequip_item(equipment_type slot, bool msg)
{
ASSERT(slot > EQ_NONE && slot < NUM_EQUIP);
ASSERT(!you.melded[slot] || you.equip[slot] != -1);
const int item_slot = you.equip[slot];
if (item_slot == -1)
return (false);
else
{
you.equip[slot] = -1;
if (!you.melded[slot])
_unequip_effect(slot, item_slot, msg);
else
you.melded[slot] = false;
return (true);
}
}
// Meld a slot (if equipped).
bool meld_slot(equipment_type slot, bool msg)
{
ASSERT(slot > EQ_NONE && slot < NUM_EQUIP);
ASSERT(!you.melded[slot] || you.equip[slot] != -1);
if (you.equip[slot] != -1 && !you.melded[slot])
{
you.melded[slot] = true;
_unequip_effect(slot, you.equip[slot], msg);
return (true);
}
return (false);
}
bool unmeld_slot(equipment_type slot, bool msg)
{
ASSERT(slot > EQ_NONE && slot < NUM_EQUIP);
ASSERT(!you.melded[slot] || you.equip[slot] != -1);
if (you.equip[slot] != -1 && you.melded[slot])
{
you.melded[slot] = false;
_equip_effect(slot, you.equip[slot], true, msg);
return (true);
}
return (false);
}
static void _equip_weapon_effect(item_def& item, bool showMsgs);
static void _unequip_weapon_effect(item_def& item, bool showMsgs);
static void _equip_armour_effect(item_def& arm, bool unmeld);
static void _unequip_armour_effect(item_def& item);
static void _equip_jewellery_effect(item_def &item);
static void _unequip_jewellery_effect(item_def &item, bool mesg);
static void _equip_effect(equipment_type slot, int item_slot, bool unmeld, bool msg)
{
item_def& item = you.inv[item_slot];
equipment_type eq = get_item_slot(item);
if (slot == EQ_WEAPON && eq != EQ_WEAPON)
return;
ASSERT(slot == eq
|| eq == EQ_RINGS
&& (slot == EQ_LEFT_RING || slot == EQ_RIGHT_RING));
if (slot == EQ_WEAPON)
_equip_weapon_effect(item, msg);
else if (slot >= EQ_CLOAK && slot <= EQ_BODY_ARMOUR)
_equip_armour_effect(item, unmeld);
else if (slot >= EQ_LEFT_RING && slot <= EQ_AMULET)
_equip_jewellery_effect(item);
}
static void _unequip_effect(equipment_type slot, int item_slot, bool msg)
{
item_def& item = you.inv[item_slot];
equipment_type eq = get_item_slot(item);
if (slot == EQ_WEAPON && eq != EQ_WEAPON)
return;
ASSERT(slot == eq
|| eq == EQ_RINGS
&& (slot == EQ_LEFT_RING || slot == EQ_RIGHT_RING));
if (slot == EQ_WEAPON)
_unequip_weapon_effect(item, msg);
else if (slot >= EQ_CLOAK && slot <= EQ_BODY_ARMOUR)
_unequip_armour_effect(item);
else if (slot >= EQ_LEFT_RING && slot <= EQ_AMULET)
_unequip_jewellery_effect(item, msg);
}
///////////////////////////////////////////////////////////
// Actual equip and unequip effect implementation below
//
static void _equip_artefact_effect(item_def &item, bool *show_msgs=NULL,
bool unmeld=false)
{
#define unknown_proprt(prop) (proprt[(prop)] && !known[(prop)])
ASSERT( is_artefact( item ) );
// Call unrandart equip function first, so that it can modify the
// artefact's properties before they're applied.
if (is_unrandom_artefact( item ))
{
const unrandart_entry *entry = get_unrand_entry(item.special);
if (entry->equip_func)
entry->equip_func(&item, show_msgs, unmeld);
if (entry->world_reacts_func)
{
equipment_type eq = get_item_slot(item.base_type, item.sub_type);
you.unrand_reacts |= (1 << eq);
}
}
const bool alreadyknown = item_type_known(item);
const bool dangerous = player_in_a_dangerous_place();
artefact_properties_t proprt;
artefact_known_props_t known;
artefact_wpn_properties( item, proprt, known );
// Only give property messages for previously unknown properties.
if (proprt[ARTP_AC])
{
you.redraw_armour_class = true;
if (!known[ARTP_AC])
{
mprf("You feel %s.", proprt[ARTP_AC] > 0?
"well-protected" : "more vulnerable");
artefact_wpn_learn_prop(item, ARTP_AC);
}
}
if (proprt[ARTP_EVASION])
{
you.redraw_evasion = true;
if (!known[ARTP_EVASION])
{
mprf("You feel somewhat %s.", proprt[ARTP_EVASION] > 0?
"nimbler" : "more awkward");
artefact_wpn_learn_prop(item, ARTP_EVASION);
}
}
if (proprt[ARTP_PONDEROUS])
{
mpr("You feel rather ponderous.");
che_handle_change(CB_PONDEROUS, 1);
}
if (proprt[ARTP_MAGICAL_POWER] && !known[ARTP_MAGICAL_POWER])
{
canned_msg(proprt[ARTP_MAGICAL_POWER] > 0 ? MSG_MANA_INCREASE
: MSG_MANA_DECREASE);
artefact_wpn_learn_prop(item, ARTP_MAGICAL_POWER);
}
// Modify ability scores.
// Output result even when identified (because of potential fatality).
notify_stat_change( STAT_STR, proprt[ARTP_STRENGTH], false, item );
notify_stat_change( STAT_INT, proprt[ARTP_INTELLIGENCE], false, item );
notify_stat_change( STAT_DEX, proprt[ARTP_DEXTERITY], false, item );
const artefact_prop_type stat_props[3] =
{ARTP_STRENGTH, ARTP_INTELLIGENCE, ARTP_DEXTERITY};
for (int i = 0; i < 3; i++)
if (unknown_proprt(stat_props[i]))
artefact_wpn_learn_prop(item, stat_props[i]);
// For evokable stuff, check whether other equipped items yield
// the same ability. If not, and if the ability granted hasn't
// already been discovered, give a message.
if (unknown_proprt(ARTP_LEVITATE)
&& !items_give_ability(item.link, ARTP_LEVITATE))
{
if (you.airborne())
mpr("You feel vaguely more buoyant than before.");
else
mpr("You feel buoyant.");
artefact_wpn_learn_prop(item, ARTP_LEVITATE);
}
if (unknown_proprt(ARTP_INVISIBLE) && !you.duration[DUR_INVIS])
{
mpr("You become transparent for a moment.");
artefact_wpn_learn_prop(item, ARTP_INVISIBLE);
}
if (unknown_proprt(ARTP_BERSERK)
&& !items_give_ability(item.link, ARTP_BERSERK))
{
mpr("You feel a brief urge to hack something to bits.");
artefact_wpn_learn_prop(item, ARTP_BERSERK);
}
if (!unmeld && !item.cursed() && proprt[ARTP_CURSED] > 0
&& one_chance_in(proprt[ARTP_CURSED]))
{
do_curse_item( item, false );
artefact_wpn_learn_prop(item, ARTP_CURSED);
}
if (proprt[ARTP_NOISES])
you.attribute[ATTR_NOISES] = 1;
if (!alreadyknown && Options.autoinscribe_artefacts)
add_autoinscription(item, artefact_auto_inscription(item));
if (!alreadyknown && dangerous)
{
// Xom loves it when you use an unknown random artefact and
// there is a dangerous monster nearby...
xom_is_stimulated(128);
}
// Let's try this here instead of up there.
if (proprt[ARTP_MAGICAL_POWER])
calc_mp();
#undef unknown_proprt
}
static void _unequip_artefact_effect(const item_def &item, bool *show_msgs=NULL)
{
ASSERT( is_artefact( item ) );
artefact_properties_t proprt;
artefact_known_props_t known;
artefact_wpn_properties( item, proprt, known );
if (proprt[ARTP_AC])
{
you.redraw_armour_class = true;
if (!known[ARTP_AC])
{
mprf("You feel less %s.",
proprt[ARTP_AC] > 0? "well-protected" : "vulnerable");
}
}
if (proprt[ARTP_EVASION])
{
you.redraw_evasion = true;
if (!known[ARTP_EVASION])
{
mprf("You feel less %s.",
proprt[ARTP_EVASION] > 0? "nimble" : "awkward");
}
}
if (proprt[ARTP_PONDEROUS])
{
mpr("That put a bit of spring back into your step.");
che_handle_change(CB_PONDEROUS, -1);
}
if (proprt[ARTP_MAGICAL_POWER] && !known[ARTP_MAGICAL_POWER])
{
canned_msg(proprt[ARTP_MAGICAL_POWER] > 0 ? MSG_MANA_DECREASE
: MSG_MANA_INCREASE);
}
// Modify ability scores; always output messages.
notify_stat_change(STAT_STR, -proprt[ARTP_STRENGTH], false, item,
true);
notify_stat_change(STAT_INT, -proprt[ARTP_INTELLIGENCE], false, item,
true);
notify_stat_change(STAT_DEX, -proprt[ARTP_DEXTERITY], false, item,
true);
if (proprt[ARTP_NOISES] != 0)
you.attribute[ATTR_NOISES] = 0;
if (proprt[ARTP_LEVITATE] != 0
&& you.duration[DUR_LEVITATION] > 2
&& !you.permanent_levitation())
{
you.duration[DUR_LEVITATION] = 1;
}
if (proprt[ARTP_INVISIBLE] != 0 && you.duration[DUR_INVIS] > 1)
you.duration[DUR_INVIS] = 1;
if (proprt[ARTP_MAGICAL_POWER])
calc_mp();
if (is_unrandom_artefact(item))
{
const unrandart_entry *entry = get_unrand_entry(item.special);
if (entry->unequip_func)
entry->unequip_func(&item, show_msgs);
if (entry->world_reacts_func)
{
equipment_type eq = get_item_slot(item.base_type, item.sub_type);
you.unrand_reacts &= ~(1 << eq);
}
}
}
// Provide a function for handling initial wielding of 'special'
// weapons, or those whose function is annoying to reproduce in
// other places *cough* auto-butchering *cough*. {gdl}
static void _equip_weapon_effect(item_def& item, bool showMsgs)
{
unsigned char special = 0;
const bool artefact = is_artefact(item);
const bool known_cursed = item_known_cursed(item);
// And here we finally get to the special effects of wielding. {dlb}
switch (item.base_type)
{
case OBJ_MISCELLANY:
{
if (item.sub_type == MISC_LANTERN_OF_SHADOWS)
{
if (showMsgs)
mpr("The area is filled with flickering shadows.");
you.current_vision -= 2;
set_los_radius(you.current_vision);
you.attribute[ATTR_SHADOWS] = 1;
}
else if (item.sub_type == MISC_HORN_OF_GERYON)
set_ident_flags(item, ISFLAG_IDENT_MASK);
break;
}
case OBJ_STAVES:
{
if (item.sub_type == STAFF_POWER)
{
int mp = item.special - you.elapsed_time / POWER_DECAY;
if (mp > 0)
you.magic_points += mp;
if ((you.max_magic_points + 13) *
(1.0+player_mutation_level(MUT_HIGH_MAGIC)/10.0) > 50)
mpr("You feel your mana capacity is already quite full.");
else
canned_msg(MSG_MANA_INCREASE);
calc_mp();
set_ident_type(item, ID_KNOWN_TYPE);
set_ident_flags(item, ISFLAG_EQ_WEAPON_MASK);
}
else if (!maybe_identify_staff(item))
{
// Give curse status when wielded.
// Right now that's always "uncursed". -- bwr
set_ident_flags(item, ISFLAG_KNOW_CURSE);
}
// Automatically identify rods; you can do this by wielding and then
// evoking them, so do it automatically instead. We don't need to give
// a message either, as the game will do that automatically. {due}
if (item_is_rod(item))
{
if (!item_type_known(item))
{
set_ident_type( OBJ_STAVES, item.sub_type, ID_KNOWN_TYPE );
set_ident_flags( item, ISFLAG_KNOW_TYPE );
}
if (!item_ident( item, ISFLAG_KNOW_PLUSES))
set_ident_flags( item, ISFLAG_KNOW_PLUSES );
}
break;
}
case OBJ_WEAPONS:
{
if (showMsgs)
{
if (is_holy_item(item) && you.religion == GOD_YREDELEMNUL)
mpr("You really shouldn't be using a holy item like this.");
else if (is_unholy_item(item) && is_good_god(you.religion))
mpr("You really shouldn't be using an unholy item like this.");
else if (is_evil_item(item) && is_good_god(you.religion))
mpr("You really shouldn't be using an evil item like this.");
else if (is_chaotic_item(item) && you.religion == GOD_ZIN)
mpr("You really shouldn't be using a chaotic item like this.");
else if (is_hasty_item(item) && you.religion == GOD_CHEIBRIADOS)
mpr("You really shouldn't be using a fast item like this.");
}
// Call unrandrt equip func before item is identified.
if (artefact)
_equip_artefact_effect(item, &showMsgs);
const bool was_known = item_type_known(item);
bool known_recurser = false;
set_ident_flags(item, ISFLAG_EQ_WEAPON_MASK);
special = item.special;
if (artefact)
{
special = artefact_wpn_property(item, ARTP_BRAND);
if (!was_known)
{
item.flags |= ISFLAG_NOTED_ID;
if (Options.autoinscribe_artefacts)
add_autoinscription(item, artefact_auto_inscription(item));
// Make a note of it.
take_note(Note(NOTE_ID_ITEM, 0, 0, item.name(DESC_NOCAP_A).c_str(),
origin_desc(item).c_str()));
}
else
known_recurser = artefact_known_wpn_property(item,
ARTP_CURSED);
}
if (special != SPWPN_NORMAL)
{
// message first
if (showMsgs)
{
switch (special)
{
case SPWPN_FLAMING:
mpr("It bursts into flame!");
break;
case SPWPN_FREEZING:
mpr("It glows with a cold blue light!");
break;
case SPWPN_HOLY_WRATH:
mpr("It softly glows with a divine radiance!");
break;
case SPWPN_ELECTROCUTION:
if (!silenced(you.pos()))
{
mpr("You hear the crackle of electricity.",
MSGCH_SOUND);
}
else
mpr("You see sparks fly.");
break;
case SPWPN_ORC_SLAYING:
mpr((you.species == SP_HILL_ORC)
? "You feel a sudden desire to commit suicide."
: "You feel a sudden desire to kill orcs!");
break;
case SPWPN_DRAGON_SLAYING:
mpr(player_genus(GENPC_DRACONIAN)
|| you.attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON
? "You feel a sudden desire to commit suicide."
: "You feel a sudden desire to slay dragons!");
break;
case SPWPN_VENOM:
mpr("It begins to drip with poison!");
break;
case SPWPN_PROTECTION:
mpr("You feel protected!");
break;
case SPWPN_EVASION:
mpr("You feel nimbler!");
break;
case SPWPN_DRAINING:
mpr("You sense an unholy aura.");
break;
case SPWPN_SPEED:
mprf("Your %s tingle!",
you.hand_name(true).c_str());
break;
case SPWPN_FLAME:
mpr("It bursts into flame!");
break;
case SPWPN_FROST:
mpr("It is covered in frost.");
break;
case SPWPN_VAMPIRICISM:
if (you.species == SP_VAMPIRE)
{
mpr("You feel a bloodthirsty glee!");
break;
}
if (you.is_undead == US_ALIVE)
{
mpr("You feel a dreadful hunger.");
// takes player from Full to Hungry
make_hungry(4500, false, false);
}
else
mpr("You feel an empty sense of dread.");
break;
case SPWPN_RETURNING:
mpr("It wiggles slightly.");
break;
case SPWPN_PAIN:
if (you.skills[SK_NECROMANCY] == 0)
mpr("You have a feeling of ineptitude.");
else if(you.skills[SK_NECROMANCY] <= 4)
mpr("Pain shudders through your arm!");
else
mpr("A searing pain shoots up your arm!");
break;
case SPWPN_CHAOS:
mpr("It is briefly surrounded by a scintillating aura "
"of random colours.");
break;
case SPWPN_PENETRATION:
mprf("Your %s briefly pass through it before you manage "
"to get a firm grip on it.",
you.hand_name(true).c_str());
break;
case SPWPN_REAPING:
mpr("It is briefly surrounded by shifting shadows.");
break;
default:
break;
}
}
// effect second
switch (special)
{
case SPWPN_PROTECTION:
you.redraw_armour_class = true;
break;
case SPWPN_EVASION:
you.redraw_evasion = true;
break;
case SPWPN_DISTORTION:
mpr("Space warps around you for a moment!");
if (!was_known)
{
// Xom loves it when you ID a distortion weapon this way,
// and even more so if he gifted the weapon himself.
god_type god;
if (origin_is_god_gift(item, &god) && god == GOD_XOM)
xom_is_stimulated(255);
else
xom_is_stimulated(128);
}
break;
default:
break;
}
}
if (item.cursed())
{
mpr("It sticks to your hand!");
int amusement = 16;
if (!known_cursed && !known_recurser)
{
amusement *= 2;
god_type god;
if (origin_is_god_gift(item, &god) && god == GOD_XOM)
amusement *= 2;
}
const int wpn_skill = weapon_skill(item.base_type, item.sub_type);
if (wpn_skill != SK_FIGHTING && you.skills[wpn_skill] == 0)
amusement *= 2;
xom_is_stimulated(amusement);
}
break;
}
default:
break;
}
if (showMsgs)
warn_shield_penalties();
you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED] = 0;
}
static void _unequip_weapon_effect(item_def& item, bool showMsgs)
{
you.m_quiver->on_weapon_changed();
// Call this first, so that the unrandart func can set showMsgs to
// false if it does its own message handling.
if (is_artefact(item))
_unequip_artefact_effect(item, &showMsgs);
if (item.base_type == OBJ_MISCELLANY
&& item.sub_type == MISC_LANTERN_OF_SHADOWS )
{
you.current_vision += 2;
set_los_radius(you.current_vision);
you.attribute[ATTR_SHADOWS] = 0;
}
else if (item.base_type == OBJ_WEAPONS)
{
const int brand = get_weapon_brand( item );
if (brand != SPWPN_NORMAL)
{
const std::string msg = item.name(DESC_CAP_YOUR);
switch (brand)
{
case SPWPN_FLAMING:
if (showMsgs)
mprf("%s stops flaming.", msg.c_str());
break;
case SPWPN_FREEZING:
case SPWPN_HOLY_WRATH:
if (showMsgs)
mprf("%s stops glowing.", msg.c_str());
break;
case SPWPN_ELECTROCUTION:
if (showMsgs)
mprf("%s stops crackling.", msg.c_str());
break;
case SPWPN_VENOM:
if (showMsgs)
mprf("%s stops dripping with poison.", msg.c_str());
break;
case SPWPN_PROTECTION:
if (showMsgs)
mpr("You feel less protected.");
you.redraw_armour_class = true;
break;
case SPWPN_EVASION:
if (showMsgs)
mpr("You feel like more of a target.");
you.redraw_evasion = true;
break;
case SPWPN_VAMPIRICISM:
if (showMsgs)
{
if (you.species == SP_VAMPIRE)
mpr("You feel your glee subside.");
else
mpr("You feel the dreadful sensation subside.");
}
break;
case SPWPN_DISTORTION:
// Removing the translocations skill reduction of effect,
// it might seem sensible, but this brand is supposed
// to be dangerous because it does large bonus damage,
// as well as free teleport other side effects, and
// even with the miscast effects you can rely on the
// occasional spatial bonus to mow down some opponents.
// It's far too powerful without a real risk, especially
// if it's to be allowed as a player spell. -- bwr
// int effect = 9 -
// random2avg(you.skills[SK_TRANSLOCATIONS] * 2, 2);
if (you.duration[DUR_WEAPON_BRAND] == 0)
{
// Makes no sense to discourage unwielding a temporarily
// branded weapon since you can wait it out. This also
// fixes problems with unwield prompts (mantis #793).
MiscastEffect(&you, WIELD_MISCAST, SPTYP_TRANSLOCATION,
9, 90, "distortion unwield");
}
break;
// NOTE: When more are added here, *must* duplicate unwielding
// effect in vorpalise weapon scroll effect in read_scoll.
}
if (you.duration[DUR_WEAPON_BRAND])
{
you.duration[DUR_WEAPON_BRAND] = 0;
set_item_ego_type(item, OBJ_WEAPONS, SPWPN_NORMAL);
// We're letting this through even if hiding messages.
mpr("Your branding evaporates.");
}
}
}
else if (item.base_type == OBJ_STAVES && item.sub_type == STAFF_POWER)
{
int mp = you.magic_points;
calc_mp();
mp -= you.magic_points;
// Store the MP in case you'll re-wield quickly.
item.special = mp + you.elapsed_time / POWER_DECAY;
canned_msg(MSG_MANA_DECREASE);
}
}
static void _equip_armour_effect(item_def& arm, bool unmeld)
{
const bool known_cursed = item_known_cursed(arm);
int ego = get_armour_ego_type( arm );
if (ego != SPARM_NORMAL)
{
switch (ego)
{
case SPARM_RUNNING:
mpr("You feel quick.");
break;
case SPARM_FIRE_RESISTANCE:
mpr("You feel resistant to fire.");
break;
case SPARM_COLD_RESISTANCE:
mpr("You feel resistant to cold.");
break;
case SPARM_POISON_RESISTANCE:
mpr("You feel healthy.");
break;
case SPARM_SEE_INVISIBLE:
mpr("You feel perceptive.");
break;
case SPARM_DARKNESS:
if (!you.duration[DUR_INVIS])
mpr("You become transparent for a moment.");
break;
case SPARM_STRENGTH:
notify_stat_change(STAT_STR, 3, false, arm);
break;
case SPARM_DEXTERITY:
notify_stat_change(STAT_DEX, 3, false, arm);
break;
case SPARM_INTELLIGENCE:
notify_stat_change(STAT_INT, 3, false, arm);
break;
case SPARM_PONDEROUSNESS:
mpr("You feel rather ponderous.");
che_handle_change(CB_PONDEROUS, 1);
you.redraw_evasion = true;
break;
case SPARM_LEVITATION:
mpr("You feel rather light.");
break;
case SPARM_MAGIC_RESISTANCE:
mpr("You feel resistant to magic.");
break;
case SPARM_PROTECTION:
mpr("You feel protected.");
break;
case SPARM_STEALTH:
mpr("You feel stealthy.");
break;
case SPARM_RESISTANCE:
mpr("You feel resistant to extremes of temperature.");
break;
case SPARM_POSITIVE_ENERGY:
mpr("Your life force is being protected.");
break;
case SPARM_ARCHMAGI:
if (!you.skills[SK_SPELLCASTING])
mpr("You feel strangely numb.");
else
mpr("You feel extremely powerful.");
break;
case SPARM_SPIRIT_SHIELD:
if (player_spirit_shield() < 2)
{
set_mp(0, false);
mpr("You feel spirits watching over you.");
if (you.species == SP_DEEP_DWARF)
mpr("Now linked to your health, your magic stops regenerating.");
}
break;
case SPARM_ARCHERY:
mpr("You feel that your aim is more steady.");
break;
}
}
if (is_artefact(arm))
{
bool show_msgs = true;
_equip_artefact_effect(arm, &show_msgs, unmeld);
}
if (arm.cursed() && !unmeld)
{
mpr("Oops, that feels deathly cold.");
learned_something_new(HINT_YOU_CURSED);
if (!known_cursed)
{
int amusement = 64;
// Cursed cloaks prevent you from removing body armour.
// Cursed gloves prevent switching of rings.
if (get_armour_slot(arm) == EQ_CLOAK
|| get_armour_slot(arm) == EQ_GLOVES)
{
amusement *= 2;
}
god_type god;
if (origin_is_god_gift(arm, &god) && god == GOD_XOM)
amusement *= 2;
xom_is_stimulated(amusement);
}
}
if (get_item_slot(arm) == EQ_SHIELD)
warn_shield_penalties();
you.redraw_armour_class = true;
you.redraw_evasion = true;
}
static void _unequip_armour_effect(item_def& item)
{
you.redraw_armour_class = true;
you.redraw_evasion = true;
switch (get_armour_ego_type(item))
{
case SPARM_RUNNING:
mpr("You feel rather sluggish.");
break;
case SPARM_FIRE_RESISTANCE:
mpr("\"Was it this warm in here before?\"");
break;
case SPARM_COLD_RESISTANCE:
mpr("You catch a bit of a chill.");
break;
case SPARM_POISON_RESISTANCE:
if (!player_res_poison())
mpr("You feel less healthy.");
break;
case SPARM_SEE_INVISIBLE:
if (!you.can_see_invisible())
mpr("You feel less perceptive.");
break;
case SPARM_DARKNESS: // I do not understand this {dlb}
if (you.duration[DUR_INVIS])
you.duration[DUR_INVIS] = 1;
break;
case SPARM_STRENGTH:
notify_stat_change(STAT_STR, -3, false, item, true);
break;
case SPARM_DEXTERITY:
notify_stat_change(STAT_DEX, -3, false, item, true);
break;
case SPARM_INTELLIGENCE:
notify_stat_change(STAT_INT, -3, false, item, true);
break;
case SPARM_PONDEROUSNESS:
mpr("That put a bit of spring back into your step.");
che_handle_change(CB_PONDEROUS, -1);
break;
case SPARM_LEVITATION:
if (you.duration[DUR_LEVITATION])
you.duration[DUR_LEVITATION] = 1;
break;
case SPARM_MAGIC_RESISTANCE:
mpr("You feel less resistant to magic.");
break;
case SPARM_PROTECTION:
mpr("You feel less protected.");
break;
case SPARM_STEALTH:
mpr("You feel less stealthy.");
break;
case SPARM_RESISTANCE:
mpr("You feel hot and cold all over.");
break;
case SPARM_POSITIVE_ENERGY:
mpr("You feel vulnerable.");
break;
case SPARM_ARCHMAGI:
mpr("You feel strangely numb.");
break;
case SPARM_SPIRIT_SHIELD:
if (!player_spirit_shield())
{
mpr("You feel strangely alone.");
if (you.species == SP_DEEP_DWARF)
mpr("Your magic begins regenerating once more.");
}
else if (player_equip(EQ_AMULET, AMU_GUARDIAN_SPIRIT, true))
{
item_def& amu(you.inv[you.equip[EQ_AMULET]]);
if (!item_type_known(amu))
{
set_ident_type(amu.base_type, amu.sub_type, ID_KNOWN_TYPE);
set_ident_flags(amu, ISFLAG_KNOW_PROPERTIES);
mprf("You are wearing: %s",
amu.name(DESC_INVENTORY_EQUIP).c_str());
}
}
break;
case SPARM_ARCHERY:
mpr("Your aim is not that steady anymore.");
break;
default:
break;
}
if (is_artefact(item))
_unequip_artefact_effect(item);
}
static void _remove_amulet_of_faith(item_def &item)
{
if (you.religion != GOD_NO_GOD
&& you.religion != GOD_XOM)
{
simple_god_message(" seems less interested in you.");
const int piety_loss = div_rand_round(you.piety, 3);
// Piety penalty for removing the Amulet of Faith.
if (you.piety - piety_loss > 10)
{
mprf(MSGCH_GOD,
"%s leaches power out of you as you remove it.",
item.name(DESC_CAP_YOUR).c_str());
dprf("%s: piety leach: %d",
item.name(DESC_PLAIN).c_str(), piety_loss);
lose_piety(piety_loss);
}
}
}
static void _equip_jewellery_effect(item_def &item)
{
item_type_id_state_type ident = ID_TRIED_TYPE;
artefact_prop_type fake_rap = ARTP_NUM_PROPERTIES;
bool learn_pluses = false;
// Randart jewellery shouldn't auto-ID just because the base type
// is known. Somehow the player should still be told, preferably
// by message. (jpeg)
const bool artefact = is_artefact(item);
const bool known_pluses = item_ident(item, ISFLAG_KNOW_PLUSES);
const bool known_cursed = item_known_cursed(item);
const bool known_bad = (item_type_known(item)
&& item_value(item) <= 2);
switch (item.sub_type)
{
case RING_FIRE:
case RING_HUNGER:
case RING_ICE:
case RING_LIFE_PROTECTION:
case RING_POISON_RESISTANCE:
case RING_PROTECTION_FROM_COLD:
case RING_PROTECTION_FROM_FIRE:
case RING_PROTECTION_FROM_MAGIC:
case RING_SUSTAIN_ABILITIES:
case RING_SUSTENANCE:
case RING_SLAYING:
case RING_WIZARDRY:
case RING_TELEPORT_CONTROL:
break;
case RING_SEE_INVISIBLE:
// We might have to turn autopickup back on again.
// TODO: Check all monsters in LOS. If any of them are invisible
// (and thus become visible once the ring is worn), the ring
// should be autoidentified.
if (item_type_known(item))
autotoggle_autopickup(false);
break;
case RING_PROTECTION:
you.redraw_armour_class = true;
if (item.plus != 0)
{
if (!artefact)
ident = ID_KNOWN_TYPE;
else if (!known_pluses)
{
mprf("You feel %s.", item.plus > 0 ?
"well-protected" : "more vulnerable");
}
learn_pluses = true;
}
break;
case RING_INVISIBILITY:
if (!you.duration[DUR_INVIS])
{
mpr("You become transparent for a moment.");
if (artefact)
fake_rap = ARTP_INVISIBLE;
else
ident = ID_KNOWN_TYPE;
}
break;
case RING_EVASION:
you.redraw_evasion = true;
if (item.plus != 0)
{
if (!artefact)
ident = ID_KNOWN_TYPE;
else if (!known_pluses)
mprf("You feel %s.", item.plus > 0? "nimbler" : "more awkward");
learn_pluses = true;
}
break;
case RING_STRENGTH:
if (item.plus)
{
notify_stat_change(STAT_STR, item.plus, false, item);
if (artefact)
fake_rap = ARTP_STRENGTH;
else
ident = ID_KNOWN_TYPE;
learn_pluses = true;
}
break;
case RING_DEXTERITY:
if (item.plus)
{
notify_stat_change(STAT_DEX, item.plus, false, item);
if (artefact)
fake_rap = ARTP_DEXTERITY;
else
ident = ID_KNOWN_TYPE;
learn_pluses = true;
}
break;
case RING_INTELLIGENCE:
if (item.plus)
{
notify_stat_change(STAT_INT, item.plus, false, item);
if (artefact)
fake_rap = ARTP_INTELLIGENCE;
else
ident = ID_KNOWN_TYPE;
learn_pluses = true;
}
break;
case RING_MAGICAL_POWER:
if ((you.max_magic_points + 9) *
(1.0+player_mutation_level(MUT_HIGH_MAGIC)/10.0) > 50)
mpr("You feel your mana capacity is already quite full.");
else
canned_msg(MSG_MANA_INCREASE);
calc_mp();
if (artefact)
fake_rap = ARTP_MAGICAL_POWER;
else
ident = ID_KNOWN_TYPE;
break;
case RING_LEVITATION:
if (!scan_artefacts(ARTP_LEVITATE))
{
if (you.airborne())
mpr("You feel vaguely more buoyant than before.");
else
mpr("You feel buoyant.");
if (artefact)
fake_rap = ARTP_LEVITATE;
else
ident = ID_KNOWN_TYPE;
}
break;
case RING_TELEPORTATION:
if (crawl_state.game_is_sprint())
mpr("You feel a slight, muted jump rush through you.");
else
mpr("You feel slightly jumpy.");
if (artefact)
fake_rap = ARTP_CAUSE_TELEPORTATION;
else
ident = ID_KNOWN_TYPE;
break;
case AMU_RAGE:
if (!scan_artefacts(ARTP_BERSERK))
{
mpr("You feel a brief urge to hack something to bits.");
if (artefact)
fake_rap = ARTP_BERSERK;
else
ident = ID_KNOWN_TYPE;
}
break;
case AMU_FAITH:
if (you.religion != GOD_NO_GOD)
{
mpr("You feel a surge of divine interest.", MSGCH_GOD);
ident = ID_KNOWN_TYPE;
}
break;
case AMU_THE_GOURMAND:
// What's this supposed to achieve? (jpeg)
you.duration[DUR_GOURMAND] = 0;
break;
case AMU_CONTROLLED_FLIGHT:
if (you.duration[DUR_LEVITATION]
&& !extrinsic_amulet_effect(AMU_CONTROLLED_FLIGHT))
{
ident = ID_KNOWN_TYPE;
}
break;
case AMU_GUARDIAN_SPIRIT:
if (player_spirit_shield() < 2)
{
set_mp(0, false);
mpr("You feel your power drawn to a protective spirit.");
if (you.species == SP_DEEP_DWARF)
mpr("Now linked to your health, your magic stops regenerating.");
ident = ID_KNOWN_TYPE;
}
break;
case RING_REGENERATION:
// To be exact, bloodless vampires should get the id only after they
// drink anything. Not worth complicating the code, IMHO. [1KB]
if (player_mutation_level(MUT_SLOW_HEALING) < 3)
ident = ID_KNOWN_TYPE;
break;
case AMU_STASIS:
int amount = you.duration[DUR_HASTE] + you.duration[DUR_SLOW];
if (you.duration[DUR_TELEPORT])
amount += 30 + random2(150);
if (amount)
{
mprf("The amulet engulfs you in a%s magical discharge!",
(amount > 250) ? " massive" :
(amount > 50) ? " violent" :
"");
ident = ID_KNOWN_TYPE;
contaminate_player(pow(amount, 0.333), item_type_known(item));
int dir = 0;
if (you.duration[DUR_HASTE])
dir++;
if (you.duration[DUR_SLOW])
dir--;
if (dir > 0)
mpr("You abruptly slow down.", MSGCH_DURATION);
else if (dir < 0)
mpr("Your slowness suddenly goes away.", MSGCH_DURATION);
if (you.duration[DUR_TELEPORT])
mpr("You feel strangely stable.", MSGCH_DURATION);
you.duration[DUR_HASTE] = 0;
you.duration[DUR_SLOW] = 0;
you.duration[DUR_TELEPORT] = 0;
}
break;
}
// Artefacts have completely different appearance than base types
// so we don't allow them to make the base types known.
if (artefact)
{
bool show_msgs = true;
_equip_artefact_effect(item, &show_msgs);
if (learn_pluses && (item.plus != 0 || item.plus2 != 0))
set_ident_flags(item, ISFLAG_KNOW_PLUSES);
if (fake_rap != ARTP_NUM_PROPERTIES)
artefact_wpn_learn_prop(item, fake_rap);
if (!item.props.exists("jewellery_tried")
|| !item.props["jewellery_tried"].get_bool())
{
item.props["jewellery_tried"].get_bool() = true;
}
}
else
{
set_ident_type(item, ident);
if (ident == ID_KNOWN_TYPE)
set_ident_flags(item, ISFLAG_EQ_JEWELLERY_MASK);
}
if (item.cursed())
{
mprf("Oops, that %s feels deathly cold.",
jewellery_is_amulet(item)? "amulet" : "ring");
learned_something_new(HINT_YOU_CURSED);
int amusement = 32;
if (!known_cursed && !known_bad)
{
amusement *= 2;
god_type god;
if (origin_is_god_gift(item, &god) && god == GOD_XOM)
amusement *= 2;
}
xom_is_stimulated(amusement);
}
// Cursed or not, we know that since we've put the ring on.
set_ident_flags(item, ISFLAG_KNOW_CURSE);
mpr(item.name(DESC_INVENTORY_EQUIP).c_str());
}
static void _unequip_jewellery_effect(item_def &item, bool mesg)
{
// The ring/amulet must already be removed from you.equip at this point.
// Turn off show_uncursed before getting the item name, because this item
// was just removed, and the player knows it's uncursed.
const bool old_showuncursed = Options.show_uncursed;
Options.show_uncursed = false;
Options.show_uncursed = old_showuncursed;
switch (item.sub_type)
{
case RING_FIRE:
case RING_HUNGER:
case RING_ICE:
case RING_LIFE_PROTECTION:
case RING_POISON_RESISTANCE:
case RING_PROTECTION_FROM_COLD:
case RING_PROTECTION_FROM_FIRE:
case RING_PROTECTION_FROM_MAGIC:
case RING_REGENERATION:
case RING_SEE_INVISIBLE:
case RING_SLAYING:
case RING_SUSTAIN_ABILITIES:
case RING_SUSTENANCE:
case RING_TELEPORTATION:
case RING_WIZARDRY:
case RING_TELEPORT_CONTROL:
break;
case RING_PROTECTION:
you.redraw_armour_class = true;
break;
case RING_EVASION:
you.redraw_evasion = true;
break;
case RING_STRENGTH:
notify_stat_change(STAT_STR, -item.plus, false, item, true);
break;
case RING_DEXTERITY:
notify_stat_change(STAT_DEX, -item.plus, false, item, true);
break;
case RING_INTELLIGENCE:
notify_stat_change(STAT_INT, -item.plus, false, item, true);
break;
case RING_LEVITATION:
if (you.duration[DUR_LEVITATION] && !you.permanent_levitation())
you.duration[DUR_LEVITATION] = 1;
break;
case RING_INVISIBILITY:
if (you.duration[DUR_INVIS])
you.duration[DUR_INVIS] = 1;
break;
case RING_MAGICAL_POWER:
canned_msg(MSG_MANA_DECREASE);
break;
case AMU_THE_GOURMAND:
you.duration[DUR_GOURMAND] = 0;
break;
case AMU_FAITH:
_remove_amulet_of_faith(item);
break;
case AMU_GUARDIAN_SPIRIT:
if (you.species == SP_DEEP_DWARF)
mpr("Your magic begins regenerating once more.");
break;
}
if (is_artefact(item))
_unequip_artefact_effect(item, &mesg);
// Must occur after ring is removed. -- bwr
calc_mp();
}
|