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
|
/*
* File: effects.cc
* Summary: Misc stuff.
* Written by: Linley Henzell
*
* Change History (most recent first):
*
* <1> -/--/-- LRH Created
*/
#include "AppHdr.h"
#include "effects.h"
#include <string.h>
#include <stdio.h>
#include "externs.h"
#include "beam.h"
#include "direct.h"
#include "dungeon.h"
#include "fight.h"
#include "itemname.h"
#include "items.h"
#include "misc.h"
#include "monplace.h"
#include "monstuff.h"
#include "mon-util.h"
#include "mutation.h"
#include "newgame.h"
#include "ouch.h"
#include "player.h"
#include "skills2.h"
#include "spells3.h"
#include "spl-book.h"
#include "spl-util.h"
#include "stuff.h"
#include "view.h"
#include "wpn-misc.h"
void summon_butter(void);
// torment_monsters is called with power 0 because torment is
// UNRESISTABLE except for being undead or having torment
// resistance! Even if we used maximum power of 1000, high
// level monsters and characters would save too often. (GDL)
static int torment_monsters(int x, int y, int pow, int garbage)
{
// is player?
if (x == you.x_pos && y == you.y_pos)
{
if (you.is_undead || you.mutation[MUT_TORMENT_RESISTANCE])
mpr("You feel a surge of unholy energy.");
else
{
mpr("Your body is wracked with pain!");
dec_hp((you.hp / 2) - 1, false);
}
return 1;
}
// check for monster in cell
int mon = mgrd[x][y];
if (mon == NON_MONSTER)
return 0;
struct monsters *monster = &menv[mon];
if (monster->type == -1)
return 0;
if (mons_res_negative_energy( monster ) >= 3)
return 0;
monster->hit_points = 1 + (monster->hit_points / 2);
simple_monster_message(monster, " convulses!");
return 1;
}
void torment(int tx, int ty)
{
apply_area_within_radius(torment_monsters, tx, ty, 0, 8, 0);
} // end torment()
void banished(unsigned char gate_type)
{
you_teleport2(false);
// this is to ensure that you're standing on a suitable space (67)
grd[you.x_pos][you.y_pos] = gate_type;
down_stairs(true, you.your_level); // heh heh
untag_followers(); // safety
} // end banished()
bool forget_spell(void)
{
unsigned char spc2;
unsigned int safety = 0; // to prevent infinite looping {dlb}
if (you.spell_no < 1)
return false;
do
{
spc2 = random2(25);
// begin safety check -- {dlb}
safety++;
if (safety > 1000)
return false;
// -- end safety check {dlb}
}
while (you.spells[spc2] == SPELL_NO_SPELL);
you.spell_no--;
you.spells[spc2] = SPELL_NO_SPELL;
return true;
} // end forget_spell()
// use player::decrease_stats() instead iff:
// (a) player_sust_abil() should not factor in; and
// (b) there is no floor to the final stat values {dlb}
bool lose_stat(unsigned char which_stat, unsigned char stat_loss, bool force)
{
bool statLowered = false; // must initialize to false {dlb}
char *ptr_stat = 0; // NULL {dlb}
char *ptr_redraw = 0; // NULL {dlb}
char newValue = 0; // holds new value, for comparison to old {dlb}
// begin outputing message: {dlb}
strcpy(info, "You feel ");
// set pointers to appropriate variables: {dlb}
if (which_stat == STAT_RANDOM)
which_stat = random2(NUM_STATS);
switch (which_stat)
{
case STAT_STRENGTH:
strcat(info, "weakened");
ptr_stat = &you.strength;
ptr_redraw = &you.redraw_strength;
break;
case STAT_DEXTERITY:
strcat(info, "clumsy");
ptr_stat = &you.dex;
ptr_redraw = &you.redraw_dexterity;
break;
case STAT_INTELLIGENCE:
strcat(info, "dopey");
ptr_stat = &you.intel;
ptr_redraw = &you.redraw_intelligence;
break;
}
// scale modifier by player_sust_abil() - right-shift
// permissible because stat_loss is unsigned: {dlb}
if (!force)
stat_loss >>= player_sust_abil();
// newValue is current value less modifier: {dlb}
newValue = *ptr_stat - stat_loss;
// XXX: Death by stat loss is currently handled in the redraw code. -- bwr
if (newValue < 0)
newValue = 0;
// conceivable that stat was already *at* three
// or stat_loss zeroed by player_sust_abil(): {dlb}
//
// Actually, that code was somewhat flawed. Several race-class combos
// can start with a stat lower than three, and this block (which
// used to say '!=' would actually cause stat gain with the '< 3'
// check that used to be above. Crawl has stat-death code and I
// don't see why we shouldn't be using it here. -- bwr
if (newValue < *ptr_stat)
{
*ptr_stat = newValue;
*ptr_redraw = 1;
// handle burden change, where appropriate: {dlb}
if (ptr_stat == &you.strength)
burden_change();
statLowered = true; // that is, stat was lowered (not just changed)
}
// a warning to player that s/he cut it close: {dlb}
if (!statLowered)
strcat(info, " for a moment");
// finish outputting message: {dlb}
strcat(info, ".");
mpr(info);
return (statLowered);
} // end lose_stat()
void direct_effect(struct bolt &pbolt)
{
int damage_taken = 0;
switch (pbolt.type)
{
case DMNBM_HELLFIRE:
mpr( "You are engulfed in a burst of hellfire!" );
strcpy( pbolt.beam_name, "hellfire" );
pbolt.ex_size = 1;
pbolt.flavour = BEAM_EXPLOSION;
pbolt.type = SYM_ZAP;
pbolt.colour = RED;
pbolt.beam_source = MHITNOT;
pbolt.thrower = KILL_MON_MISSILE;
pbolt.isBeam = false;
pbolt.isTracer = false;
pbolt.hit = 20;
pbolt.damage = dice_def( 3, 20 );
explosion( pbolt );
break;
case DMNBM_SMITING:
mpr("Something smites you!");
strcpy(pbolt.beam_name, "smiting"); // for ouch
damage_taken = 7 + random2avg(11, 2);
break;
case DMNBM_BRAIN_FEED:
// lose_stat() must come last {dlb}
if (one_chance_in(3) && lose_stat(STAT_INTELLIGENCE, 1))
mpr("Something feeds on your intellect!");
else
mpr("Something tries to feed on your intellect!");
break;
case DMNBM_MUTATION:
mpr("Strange energies course through your body.");
mutate(100);
break;
}
// apply damage and handle death, where appropriate {dlb}
if (damage_taken > 0)
ouch(damage_taken, pbolt.beam_source, KILLED_BY_BEAM);
return;
} // end direct_effect()
// monster-to-monster
void mons_direct_effect(struct bolt &pbolt, int i)
{
// note the translation here - important {dlb}
int o = menv[i].foe;
struct monsters *monster = &menv[o];
int damage_taken = 0;
// annoy the target
behaviour_event(monster, ME_ANNOY, i);
switch (pbolt.type)
{
case DMNBM_HELLFIRE:
simple_monster_message(monster, " is engulfed in hellfire.");
strcpy(pbolt.beam_name, "hellfire");
pbolt.flavour = BEAM_LAVA;
damage_taken = 5 + random2(10) + random2(5);
damage_taken = mons_adjust_flavoured(monster, pbolt, damage_taken);
break;
case DMNBM_SMITING:
simple_monster_message(monster, " is smitten.");
strcpy(pbolt.beam_name, "smiting");
pbolt.flavour = BEAM_MISSILE;
damage_taken += 7 + random2avg(11, 2);
break;
case DMNBM_BRAIN_FEED: // not implemented here (nor, probably, can be)
break;
case DMNBM_MUTATION:
if (mons_holiness(monster->type) != MH_NATURAL)
simple_monster_message(monster, " is unaffected.");
else if (check_mons_magres(monster, pbolt.ench_power))
simple_monster_message(monster, " resists.");
else
monster_polymorph(monster, RANDOM_MONSTER, 100);
break;
}
// apply damage and handle death, where appropriate {dlb}
if (damage_taken > 0)
{
hurt_monster(monster, damage_taken);
if (monster->hit_points < 1)
monster_die(monster, KILL_MON_MISSILE, i);
}
return;
} // end mons_direct_effect()
void random_uselessness(unsigned char ru, unsigned char sc_read_2)
{
char wc[30];
int temp_rand = 0; // probability determination {dlb}
switch (ru)
{
case 0:
strcpy(info, "The dust glows a ");
weird_colours(random2(256), wc);
strcat(info, wc);
strcat(info, " colour!");
mpr(info);
break;
case 1:
mpr("The scroll reassembles itself in your hand!");
inc_inv_item_quantity( sc_read_2, 1 );
break;
case 2:
if (you.equip[EQ_WEAPON] != -1)
{
in_name(you.equip[EQ_WEAPON], DESC_CAP_YOUR, str_pass);
strcpy(info, str_pass);
strcat(info, " glows ");
weird_colours(random2(256), wc);
strcat(info, wc);
strcat(info, " for a moment.");
mpr(info);
}
else
{
canned_msg(MSG_NOTHING_HAPPENS);
}
break;
case 3:
strcpy(info, "You hear the distant roaring of an enraged ");
temp_rand = random2(8);
strcat(info, (temp_rand == 0) ? "frog" :
(temp_rand == 1) ? "pill bug" :
(temp_rand == 2) ? "millipede" :
(temp_rand == 3) ? "eggplant" :
(temp_rand == 4) ? "albino dragon" :
(temp_rand == 5) ? "dragon" :
(temp_rand == 6) ? "human"
: "slug");
strcat(info, "!");
mpr(info);
break;
case 4:
// josh declares mummies can't smell {dlb}
if (you.species != SP_MUMMY)
{
strcpy(info, "You smell ");
temp_rand = random2(8);
strcat(info, (temp_rand == 0) ? "coffee." :
(temp_rand == 1) ? "salt." :
(temp_rand == 2) ? "burning hair!" :
(temp_rand == 3) ? "baking bread." :
(temp_rand == 4) ? "something weird." :
(temp_rand == 5) ? "wet wool." :
(temp_rand == 6) ? "sulphur."
: "fire and brimstone!");
mpr(info);
}
break;
case 5:
mpr("You experience a momentary feeling of inescapable doom!");
break;
case 6:
strcpy(info, "Your ");
temp_rand = random2(3);
strcat(info, (temp_rand == 0) ? "ears itch." :
(temp_rand == 1) ? "brain hurts!"
: "nose twitches suddenly!");
mpr(info);
break;
case 7:
mpr("You hear the tinkle of a tiny bell.");
summon_butter();
break;
case 8:
strcpy(info, "You hear ");
temp_rand = random2(9);
strcat(info, (temp_rand == 0) ? "snatches of song" :
(temp_rand == 1) ? "a voice call someone else's name" :
(temp_rand == 2) ? "a very strange noise" :
(temp_rand == 3) ? "roaring flame" :
(temp_rand == 4) ? "a very strange noise indeed" :
(temp_rand == 5) ? "the chiming of a distant gong" :
(temp_rand == 6) ? "the bellowing of a yak" :
(temp_rand == 7) ? "a crunching sound"
: "the tinkle of an enormous bell");
strcat(info, ".");
mpr(info);
break;
}
return;
} // end random_uselessness()
bool acquirement(unsigned char force_class)
{
int thing_created = 0;
int iteration = 0;
// Remember lava!
unsigned char class_wanted = OBJ_RANDOM;
unsigned char type_wanted = OBJ_RANDOM;
unsigned char unique = 1;
unsigned char acqc = 0;
const int max_has_value = 100;
FixedVector< int, max_has_value > already_has;
char best_spell = 99;
char best_any = 99;
unsigned char keyin;
for (acqc = 0; acqc < max_has_value; acqc++)
already_has[acqc] = 0;
int spell_skills = 0;
for (int i = SK_SPELLCASTING; i <= SK_POISON_MAGIC; i++)
spell_skills += you.skills[i];
if (force_class == OBJ_RANDOM)
{
mpr("This is a scroll of acquirement!");
query:
mpr( "[a|A] Weapon [b|B] Armour [c|C] Jewellery [d|D] Book" );
mpr( "[e|E] Staff [f|F] Food [g|G] Miscellaneous [h|H] Gold" );
//mpr("[r|R] - Just give me something good.");
mpr("What kind of item would you like to acquire? ", MSGCH_PROMPT);
keyin = get_ch();
if (keyin == 'a' || keyin == 'A')
class_wanted = OBJ_WEAPONS;
else if (keyin == 'b' || keyin == 'B')
class_wanted = OBJ_ARMOUR;
else if (keyin == 'c' || keyin == 'C')
class_wanted = OBJ_JEWELLERY;
else if (keyin == 'd' || keyin == 'D')
class_wanted = OBJ_BOOKS;
else if (keyin == 'e' || keyin == 'E')
class_wanted = OBJ_STAVES;
else if (keyin == 'f' || keyin == 'F')
class_wanted = OBJ_FOOD;
else if (keyin == 'g' || keyin == 'G')
class_wanted = OBJ_MISCELLANY;
else if (keyin == 'h' || keyin == 'H')
class_wanted = OBJ_GOLD;
}
else
class_wanted = force_class;
for (acqc = 0; acqc < ENDOFPACK; acqc++)
{
if (is_valid_item( you.inv[acqc] )
&& you.inv[acqc].base_type == class_wanted)
{
ASSERT( you.inv[acqc].sub_type < max_has_value );
already_has[you.inv[acqc].sub_type] += you.inv[acqc].quantity;
}
}
if (class_wanted == OBJ_FOOD)
{
// food is a little less predicatable now -- bwr
if (you.species == SP_GHOUL)
{
type_wanted = one_chance_in(10) ? FOOD_ROYAL_JELLY
: FOOD_CHUNK;
}
else
{
// Meat is better than bread (except for herbivors), and
// by choosing it as the default we don't have to worry
// about special cases for carnivorous races (ie kobold)
type_wanted = FOOD_MEAT_RATION;
if (you.mutation[MUT_HERBIVOROUS])
type_wanted = FOOD_BREAD_RATION;
// If we have some regular rations, then we're probably be more
// interested in faster foods (escpecially royal jelly)...
// otherwise the regular rations should be a good enough offer.
if (already_has[FOOD_MEAT_RATION]
+ already_has[FOOD_BREAD_RATION] >= 2 || coinflip())
{
type_wanted = one_chance_in(5) ? FOOD_HONEYCOMB
: FOOD_ROYAL_JELLY;
}
}
// quantity is handled by unique for food
unique = 3 + random2(5);
// giving more of the lower food value items
if (type_wanted == FOOD_HONEYCOMB || type_wanted == FOOD_CHUNK)
{
unique += random2avg(10, 2);
}
}
else if (class_wanted == OBJ_WEAPONS)
{
// Now asking for a weapon is biased towards your skills,
// although launchers are right out for now. -- bwr
// Accepting the shortcoming of occasionally providing
// weapons that are unwieldable by the character (happened
// before as well)... don't feel like compilcating things
// with more duplicate code. -- bwr
int count = 0;
int skill = SK_FIGHTING;
// Can't do much with launchers, so we'll avoid them for now -- bwr
for (int i = SK_SHORT_BLADES; i <= SK_STAVES; i++)
{
if (i == SK_UNUSED_1)
continue;
// Adding a small constant allows for the occasional
// weapon in an untrained skill.
count += (you.skills[i] + 1);
if (random2(count) < you.skills[i] + 1)
skill = i;
}
if (skill == SK_STAVES)
type_wanted = WPN_QUARTERSTAFF; // only one in this class
else
{
count = 0;
// skipping clubs, knives, blowguns
for (int i = WPN_MACE; i <= WPN_GREAT_FLAIL; i++)
{
// skipping launchers
if (i == WPN_SLING)
i = WPN_GLAIVE;
// skipping giant clubs
if (i == WPN_GIANT_CLUB)
i = WPN_EVENINGSTAR;
// "rare" weapons are only considered some of the time...
// still, the chance is higher than actual random creation
if (weapon_skill( OBJ_WEAPONS, i ) == skill
&& (i < WPN_EVENINGSTAR || i > WPN_BROAD_AXE
|| (i >= WPN_HAMMER && i <= WPN_SABRE)
|| one_chance_in(4)))
{
count++;
if (one_chance_in( count ))
type_wanted = i;
}
}
}
}
else if (class_wanted == OBJ_ARMOUR)
{
// Increasing the representation of the non-body armour
// slots here to make up for the fact that there's one
// one type of item for most of them. -- bwr
//
// OBJ_RANDOM is body armour and handled below
type_wanted = (coinflip()) ? OBJ_RANDOM : ARM_SHIELD + random2(5);
// mutation specific problems (horns allow caps)
if ((you.mutation[MUT_HOOVES] && type_wanted == ARM_BOOTS)
|| (you.mutation[MUT_CLAWS] >= 3 && type_wanted == ARM_GLOVES))
{
type_wanted = OBJ_RANDOM;
}
// some species specific fitting problems
switch (you.species)
{
case SP_OGRE:
case SP_OGRE_MAGE:
case SP_TROLL:
case SP_SPRIGGAN:
if (type_wanted == ARM_GLOVES || type_wanted == ARM_BOOTS)
{
type_wanted = OBJ_RANDOM;
}
else if (type_wanted == ARM_SHIELD)
{
if (you.species == SP_SPRIGGAN)
type_wanted = ARM_BUCKLER;
else if (coinflip()) // giant races: 50/50 shield/large shield
type_wanted = ARM_LARGE_SHIELD;
}
else if (type_wanted == OBJ_RANDOM)
{
type_wanted = ARM_ROBE; // no heavy armour, see below
}
break;
case SP_KENKU:
if (type_wanted == ARM_BOOTS)
type_wanted = OBJ_RANDOM;
break;
default:
break;
}
// Now we'll randomly pick a body armour (light only in the
// case of ARM_ROBE). Unlike before, now we're only giving
// out the finished products here, never the hides. -- bwr
if (type_wanted == OBJ_RANDOM || type_wanted == ARM_ROBE)
{
// start with normal base armour
if (type_wanted == ARM_ROBE)
type_wanted = coinflip() ? ARM_ROBE : ARM_ANIMAL_SKIN;
else
{
type_wanted = ARM_ROBE + random2(8);
if (one_chance_in(10) && you.skills[SK_ARMOUR] >= 10)
type_wanted = ARM_CRYSTAL_PLATE_MAIL;
if (one_chance_in(10))
type_wanted = ARM_ANIMAL_SKIN;
}
// everyone can wear things made from hides
if (one_chance_in(20))
{
int rnd = random2(20);
type_wanted = (rnd < 4) ? ARM_TROLL_LEATHER_ARMOUR : // 20%
(rnd < 8) ? ARM_STEAM_DRAGON_ARMOUR : // 20%
(rnd < 11) ? ARM_MOTTLED_DRAGON_ARMOUR : // 15%
(rnd < 14) ? ARM_SWAMP_DRAGON_ARMOUR : // 15%
(rnd < 16) ? ARM_DRAGON_ARMOUR : // 10%
(rnd < 18) ? ARM_ICE_DRAGON_ARMOUR : // 10%
(rnd < 19) ? ARM_STORM_DRAGON_ARMOUR // 5%
: ARM_GOLD_DRAGON_ARMOUR; // 5%
}
}
}
else if (class_wanted != OBJ_GOLD)
{
do
{
unsigned char i;
switch (class_wanted)
{
case OBJ_JEWELLERY:
// Try for a base type the player hasn't identified
for (i = 0; i < 10; i++)
{
type_wanted = random2(24);
if (one_chance_in(3))
type_wanted = AMU_RAGE + random2(10);
if (get_ident_type(OBJ_JEWELLERY, type_wanted) == ID_UNKNOWN_TYPE)
{
break;
}
}
break;
case OBJ_BOOKS:
// remember, put rarer books higher in the list
iteration = 1;
type_wanted = NUM_BOOKS;
best_spell = best_skill( SK_SPELLCASTING, (NUM_SKILLS - 1),
best_spell );
which_book:
#if DEBUG_DIAGNOSTICS
snprintf( info, INFO_SIZE,
"acquirement: iteration = %d, best_spell = %d",
iteration, best_spell );
mpr( info, MSGCH_DIAGNOSTIC );
#endif //jmf: debugging
switch (best_spell)
{
default:
case SK_SPELLCASTING:
if (you.skills[SK_SPELLCASTING] <= 3
&& !you.had_book[BOOK_CANTRIPS])
{
// Handful of level one spells, very useful for the
// new spellcaster who's asking for a book -- bwr
type_wanted = BOOK_CANTRIPS;
}
else if (!you.had_book[BOOK_WIZARDRY])
type_wanted = BOOK_WIZARDRY;
else if (!you.had_book[BOOK_CONTROL])
type_wanted = BOOK_CONTROL;
else if (!you.had_book[BOOK_POWER])
type_wanted = BOOK_POWER;
break;
case SK_POISON_MAGIC:
if (!you.had_book[BOOK_YOUNG_POISONERS])
type_wanted = BOOK_YOUNG_POISONERS;
else if (!you.had_book[BOOK_ENVENOMATIONS])
type_wanted = BOOK_ENVENOMATIONS;
break;
case SK_EARTH_MAGIC:
if (!you.had_book[BOOK_GEOMANCY])
type_wanted = BOOK_GEOMANCY;
else if (!you.had_book[BOOK_EARTH])
type_wanted = BOOK_EARTH;
break;
case SK_AIR_MAGIC:
// removed the book of clouds... all the other elements
// (and most other spell skills) only get two.
if (!you.had_book[BOOK_AIR])
type_wanted = BOOK_AIR;
else if (!you.had_book[BOOK_SKY])
type_wanted = BOOK_SKY;
break;
case SK_ICE_MAGIC:
if (!you.had_book[BOOK_FROST])
type_wanted = BOOK_FROST;
else if (!you.had_book[BOOK_ICE])
type_wanted = BOOK_ICE;
break;
case SK_FIRE_MAGIC:
if (!you.had_book[BOOK_FLAMES])
type_wanted = BOOK_FLAMES;
else if (!you.had_book[BOOK_FIRE])
type_wanted = BOOK_FIRE;
break;
case SK_SUMMONINGS:
if (!you.had_book[BOOK_CALLINGS])
type_wanted = BOOK_CALLINGS;
else if (!you.had_book[BOOK_SUMMONINGS])
type_wanted = BOOK_SUMMONINGS;
// now a Vehumet special -- bwr
// else if (!you.had_book[BOOK_DEMONOLOGY])
// type_wanted = BOOK_DEMONOLOGY;
break;
case SK_ENCHANTMENTS:
best_any = best_skill(SK_FIGHTING, (NUM_SKILLS - 1), 99);
// So many enchantment books! I really can't feel
// guilty at all for dividing out the fighting
// books and forcing the player to raise a fighting
// skill (or enchantments in the case of Crusaders)
// to get the remaining books... enchantments are
// much too good (most spells, lots of books here,
// id wand charges, gives magic resistance),
// something will eventually have to be done. -- bwr
if (best_any >= SK_FIGHTING
&& best_any <= SK_STAVES)
{
// Fighter mage's get the fighting enchantment books
if (!you.had_book[BOOK_WAR_CHANTS])
type_wanted = BOOK_WAR_CHANTS;
else if (!you.had_book[BOOK_TUKIMA])
type_wanted = BOOK_TUKIMA;
}
else if (!you.had_book[BOOK_CHARMS])
type_wanted = BOOK_CHARMS;
else if (!you.had_book[BOOK_HINDERANCE])
type_wanted = BOOK_HINDERANCE;
else if (!you.had_book[BOOK_ENCHANTMENTS])
type_wanted = BOOK_ENCHANTMENTS;
else if (!you.had_book[BOOK_CONTROL])
type_wanted = BOOK_CONTROL;
break;
case SK_CONJURATIONS:
if (!you.had_book[BOOK_CONJURATIONS_I])
type_wanted = give_first_conjuration_book();
else if (!you.had_book[BOOK_TEMPESTS])
type_wanted = BOOK_TEMPESTS;
// now a Vehumet special -- bwr
// else if (!you.had_book[BOOK_ANNIHILATIONS])
// type_wanted = BOOK_ANNIHILATIONS;
break;
case SK_NECROMANCY:
if (!you.had_book[BOOK_NECROMANCY])
type_wanted = BOOK_NECROMANCY;
else if (!you.had_book[BOOK_DEATH])
type_wanted = BOOK_DEATH;
else if (!you.had_book[BOOK_UNLIFE])
type_wanted = BOOK_UNLIFE;
// now a Kikubaaqudgha special -- bwr
// else if (!you.had_book[BOOK_NECRONOMICON])
// type_wanted = BOOK_NECRONOMICON;
break;
case SK_TRANSLOCATIONS:
if (!you.had_book[BOOK_SPATIAL_TRANSLOCATIONS])
type_wanted = BOOK_SPATIAL_TRANSLOCATIONS;
else if (!you.had_book[BOOK_WARP])
type_wanted = BOOK_WARP;
break;
case SK_TRANSMIGRATION:
if (!you.had_book[BOOK_CHANGES])
type_wanted = BOOK_CHANGES;
else if (!you.had_book[BOOK_TRANSFIGURATIONS])
type_wanted = BOOK_TRANSFIGURATIONS;
else if (!you.had_book[BOOK_MUTATIONS])
type_wanted = BOOK_MUTATIONS;
break;
case SK_DIVINATIONS: //jmf: added 24mar2000
if (!you.had_book[BOOK_SURVEYANCES])
type_wanted = BOOK_SURVEYANCES;
else if (!you.had_book[BOOK_DIVINATIONS])
type_wanted = BOOK_DIVINATIONS;
break;
}
/*
if (type_wanted == 99 && glof == best_skill(SK_SPELLCASTING, (NUM_SKILLS - 1), 99))
*/
if (type_wanted == NUM_BOOKS && iteration == 1)
{
best_spell = best_skill( SK_SPELLCASTING, (NUM_SKILLS - 1),
best_skill(SK_SPELLCASTING,
(NUM_SKILLS - 1), 99) );
iteration++;
goto which_book;
}
// if we don't have a book, try and get a new one.
if (type_wanted == NUM_BOOKS)
{
do
{
type_wanted = random2(NUM_BOOKS);
if (one_chance_in(500))
break;
}
while (you.had_book[type_wanted]);
}
// if the book is invalid find any valid one.
while (book_rarity(type_wanted) == 100
|| type_wanted == BOOK_DESTRUCTION
|| type_wanted == BOOK_MANUAL)
{
type_wanted = random2(NUM_BOOKS);
}
break;
case OBJ_STAVES:
type_wanted = random2(13);
if (type_wanted >= 10)
type_wanted = STAFF_AIR + type_wanted - 10;
// Elemental preferences -- bwr
if (type_wanted == STAFF_FIRE || type_wanted == STAFF_COLD)
{
if (you.skills[SK_FIRE_MAGIC] > you.skills[SK_ICE_MAGIC])
type_wanted = STAFF_FIRE;
else if (you.skills[SK_FIRE_MAGIC] != you.skills[SK_ICE_MAGIC])
type_wanted = STAFF_COLD;
}
else if (type_wanted == STAFF_AIR || type_wanted == STAFF_EARTH)
{
if (you.skills[SK_AIR_MAGIC] > you.skills[SK_EARTH_MAGIC])
type_wanted = STAFF_AIR;
else if (you.skills[SK_AIR_MAGIC] != you.skills[SK_EARTH_MAGIC])
type_wanted = STAFF_EARTH;
}
best_spell = best_skill( SK_SPELLCASTING, (NUM_SKILLS-1), 99 );
// If we're going to give out an enhancer stave,
// we should at least bias things towards the
// best spell skill. -- bwr
switch (best_spell)
{
case SK_FIRE_MAGIC:
if (!already_has[STAFF_FIRE])
type_wanted = STAFF_FIRE;
break;
case SK_ICE_MAGIC:
if (!already_has[STAFF_COLD])
type_wanted = STAFF_COLD;
break;
case SK_AIR_MAGIC:
if (!already_has[STAFF_AIR])
type_wanted = STAFF_AIR;
break;
case SK_EARTH_MAGIC:
if (!already_has[STAFF_EARTH])
type_wanted = STAFF_EARTH;
break;
case SK_POISON_MAGIC:
if (!already_has[STAFF_POISON])
type_wanted = STAFF_POISON;
break;
case SK_NECROMANCY:
if (!already_has[STAFF_DEATH])
type_wanted = STAFF_DEATH;
break;
case SK_CONJURATIONS:
if (!already_has[STAFF_CONJURATION])
type_wanted = STAFF_CONJURATION;
break;
case SK_ENCHANTMENTS:
if (!already_has[STAFF_ENCHANTMENT])
type_wanted = STAFF_ENCHANTMENT;
break;
case SK_SUMMONINGS:
if (!already_has[STAFF_SUMMONING])
type_wanted = STAFF_SUMMONING;
break;
default:
switch (random2(5))
{
case 0:
type_wanted = STAFF_WIZARDRY;
break;
case 1:
type_wanted = STAFF_POWER;
break;
case 2:
type_wanted = STAFF_ENERGY;
break;
case 3:
type_wanted = STAFF_CHANNELING;
break;
case 4:
break;
}
break;
}
// Increased chance of getting spell staff for new or
// non-spellcasters. Power and channeling are useful
// to characters with abilities. -- bwr
if (one_chance_in(5)
|| (spell_skills <= 1 // keeping down potential abuse
&& type_wanted != STAFF_POWER
&& type_wanted != STAFF_CHANNELING
&& coinflip()))
{
type_wanted = (coinflip() ? STAFF_STRIKING
: STAFF_SMITING + random2(10));
}
break;
case OBJ_MISCELLANY: //mv: slightly changed
do
type_wanted = random2(NUM_MISCELLANY);
while
((type_wanted == MISC_HORN_OF_GERYON) //never
|| (type_wanted == MISC_RUNE_OF_ZOT) //never
|| (type_wanted == MISC_PORTABLE_ALTAR_OF_NEMELEX)); //never
break;
default:
mesclr();
goto query;
}
ASSERT( type_wanted < max_has_value );
}
while (already_has[type_wanted] && !one_chance_in(200));
}
if (grd[you.x_pos][you.y_pos] == DNGN_LAVA
|| grd[you.x_pos][you.y_pos] == DNGN_DEEP_WATER)
{
mpr("You hear a splash."); // how sad (and stupid)
}
else
{
// BCR - unique is now used for food quantity.
thing_created = items( unique, class_wanted, type_wanted, true,
351, 250 );
if (thing_created == NON_ITEM)
{
mpr("The demon of the infinite void smiles at you.");
return (false);
}
// remove curse flag from item
do_uncurse_item( mitm[thing_created] );
if (mitm[thing_created].base_type == OBJ_BOOKS)
{
you.had_book[ mitm[thing_created].sub_type ] = 1;
}
else if (mitm[thing_created].base_type == OBJ_ARMOUR)
{
// HACK: make unwearable hats and boots wearable
switch (mitm[thing_created].sub_type)
{
case ARM_HELMET:
if ((cmp_helmet_type( mitm[thing_created], THELM_HELM )
|| cmp_helmet_type( mitm[thing_created], THELM_HELMET ))
&& ((you.species >= SP_OGRE && you.species <= SP_OGRE_MAGE)
|| player_genus(GENPC_DRACONIAN)
|| you.species == SP_MINOTAUR
|| you.species == SP_KENKU
|| you.species == SP_SPRIGGAN
|| you.mutation[MUT_HORNS]))
{
// turn it into a cap or wizard hat
set_helmet_type( mitm[thing_created],
coinflip() ? THELM_CAP : THELM_WIZARD_HAT );
mitm[thing_created].colour = random_colour();
}
break;
case ARM_BOOTS:
if (you.species == SP_NAGA)
mitm[thing_created].plus2 = TBOOT_NAGA_BARDING;
else if (you.species == SP_CENTAUR)
mitm[thing_created].plus2 = TBOOT_CENTAUR_BARDING;
else
mitm[thing_created].plus2 = TBOOT_BOOTS;
// fix illegal barding ego types caused by above hack
if (mitm[thing_created].plus2 != TBOOT_BOOTS
&& get_armour_ego_type( mitm[thing_created] ) == SPARM_RUNNING)
{
set_item_ego_type( mitm[thing_created], OBJ_ARMOUR, SPARM_NORMAL );
}
break;
default:
break;
}
}
move_item_to_grid( &thing_created, you.x_pos, you.y_pos );
// This should never actually be NON_ITEM because of the way
// move_item_to_grid works (doesn't create a new item ever),
// but we're checking it anyways. -- bwr
if (thing_created != NON_ITEM)
canned_msg(MSG_SOMETHING_APPEARS);
}
// Well, the item may have fallen in the drink, but the intent is
// that acquirement happened. -- bwr
return (true);
} // end acquirement()
bool recharge_wand(void)
{
if (you.equip[EQ_WEAPON] == -1
|| you.inv[you.equip[EQ_WEAPON]].base_type != OBJ_WANDS)
{
return (false);
}
unsigned char charge_gain = 0;
switch (you.inv[you.equip[EQ_WEAPON]].sub_type)
{
case WAND_INVISIBILITY:
case WAND_FIREBALL:
case WAND_HEALING:
charge_gain = 3;
break;
case WAND_LIGHTNING:
case WAND_DRAINING:
charge_gain = 4;
break;
case WAND_FIRE:
case WAND_COLD:
charge_gain = 5;
break;
default:
charge_gain = 8;
break;
}
in_name(you.equip[EQ_WEAPON], DESC_CAP_YOUR, str_pass);
strcpy(info, str_pass);
strcat(info, " glows for a moment.");
mpr(info);
you.inv[you.equip[EQ_WEAPON]].plus +=
1 + random2avg( ((charge_gain - 1) * 3) + 1, 3 );
if (you.inv[you.equip[EQ_WEAPON]].plus > charge_gain * 3)
you.inv[you.equip[EQ_WEAPON]].plus = charge_gain * 3;
you.wield_change = true;
return (true);
} // end recharge_wand()
void yell(void)
{
bool targ_prev = false;
int mons_targd = 0;
struct dist targ;
if (silenced(you.x_pos, you.y_pos))
{
mpr("You are unable to make a sound!");
return;
}
mpr("What do you say?", MSGCH_PROMPT);
mpr(" ! - Yell");
mpr(" a - Order allies to attack a monster");
if (!(you.prev_targ == MHITNOT || you.prev_targ == MHITYOU))
{
struct monsters *target = &menv[you.prev_targ];
if (mons_near(target) && player_monster_visible(target))
{
mpr(" p - Order allies to attack your previous target");
targ_prev = true;
}
}
strcpy(info, " Anything else - Stay silent");
if (one_chance_in(10))
strcat(info, " (and be thought a fool)");
mpr(info);
unsigned char keyn = get_ch();
switch (keyn)
{
case '!':
mpr("You yell for attention!");
you.turn_is_over = 1;
noisy(12, you.x_pos, you.y_pos);
return;
case 'a':
mpr("Gang up on whom?", MSGCH_PROMPT);
direction( targ, DIR_TARGET, TARG_ENEMY );
if (targ.isCancel)
{
canned_msg(MSG_OK);
return;
}
if (!targ.isValid || mgrd[targ.tx][targ.ty] == NON_MONSTER)
{
mpr("Yeah, whatever.");
return;
}
mons_targd = mgrd[targ.tx][targ.ty];
break;
case 'p':
if (targ_prev)
{
mons_targd = you.prev_targ;
break;
}
/* fall through... */
default:
mpr("Okely-dokely.");
return;
}
you.pet_target = mons_targd;
noisy(10, you.x_pos, you.y_pos);
mpr("Attack!");
} // end yell()
// produce caterpillars under rare circumstances?
// why did jmf change it to BEH_ENSLAVED ??? {dlb}
void summon_butter(void)
{
for (int scount = 0; scount < 8; scount++)
{
create_monster( MONS_BUTTERFLY, ENCH_ABJ_III, BEH_FRIENDLY,
you.x_pos, you.y_pos, MHITNOT, 250 );
}
} // end summon_butter()
|