Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 | 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 6097x 6097x 6093x 6097x 6097x 6097x 4x 4x 4x 4x 6097x 2x 2x 2x 6097x 6097x 6097x 13x 13x 13x 12x 12x 12x 8x 8x 8x 16x 32x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 8x 12x 12x 12x 4x 4x 12x 12x 12x 13x 13x 6097x 6097x 6097x 6097x 6097x 3x 3x 3x 3x 3x 2x 2x 2x 2x 2x 2x 2x 3x 3x 6097x 6097x 6097x 6097x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 73x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 3x 3x 3x 3x 2x 2x 2x 2x 2x 2x 2x 2x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 4x 4x 7x 1x 1x 1x 1x 7x 7x 7x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 7x 2x 7x 5x 7x 7x 73x 73x 73x 23x 23x 23x 73x 73x 73x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 23x 2x 2x 2x 21x 21x 21x 21x 21x 22x 21x 21x 21x 23x 13x 13x 13x 13x 3x 3x 3x 3x 3x 3x 13x 18x 19x 23x 23x 23x 8x 8x 23x 8x 8x 8x 8x 23x 1x 1x 1x 1x 1x 8x 7x 23x 73x 73x 73x 73x 73x 73x 73x | // sounds.js — Sound effects and monster noises (port of sounds.c)
// Handles dungeon ambient sounds and monster vocalizations.
import { game } from './gstate.js';
import { accessible } from './monmove.js';
import { rn2, rn1 } from './rng.js';
import { You, Your, You_cant, You_hear, pline, pline_The, verbalize } from './pline.js';
import { Blind, Conflict, Deaf, Hallucination, In_endgame, Invis, Is_astralevel, Is_sanctum, Role_if, Strangled, SYSOPT_SEDUCE, Underwater, Upolyd } from './macros.js';
import { COURT, ZOO, BEEHIVE, MORGUE, BARRACKS, SWAMP, TEMPLE,
ROOMOFFSET, VAULT, ANY_SHOP, SDOOR, ECMD_OK, ECMD_TIME, ECMD_CANCEL,
STRAT_WAITMASK, M_AP_FURNITURE, M_AP_OBJECT, W_ARMH, BOLT_LIM,
PLNMSG_GROWL, HEAD, NECK, HAIR, BLOOD, FULL_MOON,
IS_WALL, isok, EPRI, EDOG, M_AP_TYPE,
} from './const.js';
import { MS_SILENT, MS_BARK, MS_MEW, MS_ROAR, MS_BELLOW, MS_GROWL,
MS_SQEEK, MS_SQAWK, MS_CHIRP, MS_HISS, MS_BUZZ, MS_GRUNT, MS_NEIGH,
MS_MOO, MS_WAIL, MS_GROAN, MS_GURGLE, MS_BURBLE, MS_TRUMPET, MS_ANIMAL,
MS_SHRIEK, MS_BONES, MS_LAUGH, MS_MUMBLE, MS_IMITATE, MS_WERE, MS_ORC,
MS_HUMANOID, MS_ARREST, MS_SOLDIER, MS_GUARD, MS_DJINNI, MS_NURSE,
MS_SEDUCE, MS_VAMPIRE, MS_BRIBE, MS_CUSS, MS_RIDER, MS_LEADER,
MS_NEMESIS, MS_GUARDIAN, MS_SELL, MS_ORACLE, MS_PRIEST, MS_SPELL,
MS_BOAST,
mons, S_ANT, S_NYMPH, S_CENTAUR, S_QUADRUPED, S_EEL,
PM_DINGO, PM_RAVEN, PM_DEATH, PM_GECKO, PM_LONG_WORM, PM_ORACLE,
PM_HOBBIT, PM_ARCHEOLOGIST, PM_TOURIST, PM_WATER_DEMON, PM_PRISONER,
PM_WOLF, PM_WINTER_WOLF, PM_WINTER_WOLF_CUB,
PM_VAMPIRE, PM_VAMPIRE_LEADER,
PM_SILVER_DRAGON, PM_BABY_SILVER_DRAGON,
PM_HUMAN_WERERAT,
} from './monsters.js';
import { search_special } from './mkroom.js';
import { Monnam, aggravate, is_mplayer, mhis, mon_nam, responsive_mon_at, uhis, wake_nearto } from './mon.js';
import { nomul } from './cmd.js';
import { getdir } from './cmd.js';
import { canseemon, canspotmon, glyph_at, glyph_to_mon, map_invisible } from './display.js';
import { cansee } from './vision.js';
import { couldsee } from './vision.js';
import { helpless, money_cnt, next2u } from './hack.js';
import { m_at } from './map_access.js';
import { is_silent, is_mercenary, is_elf, is_dwarf, is_gnome, likes_magic,
carnivorous, herbivorous, is_animal, is_flyer, is_undead, is_vampshifter,
humanoid, haseyes, perceives, monsndx, is_weptool,
} from './mondata.js';
import { night, midnight } from './calendar.js';
import { body_part } from './polyself.js';
import { poly_gender } from './polyself.js';
import { could_seduce, doseduce } from './mhitu.js';
import { quest_chat, quest_talk } from './quest.js';
import { shk_chat, tended_shop, noisy_shop, price_quote, shop_object } from './shk.js';
import { vault_occupied } from './vault.js';
import { gd_sound } from './vault.js';
import { inhistemple, p_coaligned, priest_talk, temple_occupied } from './priest.js';
import { halu_gname } from './pray.js';
import { g_at } from './invent.js';
import { currency } from './invent.js';
import { which_armor } from './worn.js';
import { t_at } from './map_access.js';
import { an, helm_simple_name, vtense } from './objnam.js';
import { noveltitle, pmname, rndmonnam } from './do_name.js';
import { demon_talk, is_lminion } from './minion.js';
import { mplayer_talk } from './mplayer.js';
import { STATUE, WEAPON_CLASS } from './objects.js';
import { ROLL_FROM, ucase } from './hacklib.js';
import { EMIN, Is_oracle_level, has_emin } from './const.js';
import { same_race } from './mondata.js';
import { vobj_at } from './mkobj.js';
import { glyph_is_invisible } from './glyph.js';
// ── Local stubs for unported or unavailable functions ──
// uhis: imported from mon.js
// Is_sanctum: imported from macros.js
// is_mplayer: imported from mon.js
// is_lminion: imported from minion.js
// accessible: imported from monmove.js
function glyph_is_statue(_glyph) { return false; } // TODO
// glyph_to_mon: imported from display.js
// vobj_at: imported from mkobj.js
function doconsult(_mtmp) { return ECMD_TIME; } // TODO
// SYSOPT_SEDUCE: imported from macros.js
// aggravate: imported from mon.js
function genus(pm, _mode) { return pm; } // TODO: proper genus lookup
function Death_quote(_buf, _sz) { return false; } // TODO
function u_have_novel() { return null; } // TODO
function cursed_check(obj) { return obj?.cursed; }
// C: cuss(mtmp) — monster cusses at hero
async function cuss(mtmp) {
await pline(`${Monnam(mtmp)} casts aspersions on your ancestry.`);
}
// C ref: sounds.c h_sounds — hallucination sound verbs
const h_sounds = [
'beep', 'boing', 'sing', 'belche', 'creak', 'cough',
'rattle', 'ululate', 'pop', 'jingle', 'sniffle', 'tinkle',
'eep', 'clatter', 'hum', 'sizzle', 'twitter', 'wheeze',
'rustle', 'honk', 'lisp', 'yodel', 'coo', 'burp',
'moo', 'boom', 'murmur', 'oink', 'quack', 'rumble',
'twang', 'toot', 'gargle', 'hoot', 'warble',
];
// C ref: sounds.c:19 mon_in_room
function mon_in_room(mon, rmtyp) {
const loc = game.level?.at(mon.mx, mon.my);
if (!loc) return false;
const rno = loc.roomno ?? 0;
if (rno >= ROOMOFFSET) {
const room = game.level.rooms?.[rno - ROOMOFFSET];
return room?.rtype === rmtyp;
}
return false;
}
// C ref: sounds.c:29 throne_mon_sound — RNG: rn2
async function throne_mon_sound(mtmp) {
if (!mtmp?.data) return false;
if ((mtmp.msleeping || mtmp.data.mflags2_lord || mtmp.data.mflags2_prince)
&& !mtmp.data.mflags1_animal && mon_in_room(mtmp, COURT)) {
const throne_msg = [
'the tones of courtly conversation.',
'a sceptre pounded in judgment.',
`Someone shouts "Off with ${uhis()} head!"`,
"Queen Beruthiel's cats!",
];
const which = rn2(3) + (Hallucination() ? 1 : 0);
if (which !== 2) {
await You_hear(throne_msg[which]);
} else {
await pline(throne_msg[2]);
}
return true;
}
return false;
}
// C ref: sounds.c:61 beehive_mon_sound — RNG: rn2
async function beehive_mon_sound(mtmp) {
if (!mtmp?.data) return false;
if ((mtmp.data.mlet === S_ANT && is_flyer(mtmp.data))
&& mon_in_room(mtmp, BEEHIVE)) {
switch (rn2(2) + (Hallucination() ? 1 : 0)) {
case 0:
await You_hear('a low buzzing.');
break;
case 1:
await You_hear('an angry drone.');
break;
case 2:
await You_hear(`bees in your ${game.u.uarmh ? '' : '(nonexistent) '}bonnet!`);
break;
}
return true;
}
return false;
}
// C ref: sounds.c:88 morgue_mon_sound — RNG: rn2
async function morgue_mon_sound(mtmp) {
if (!mtmp?.data) return false;
if ((is_undead(mtmp.data) || is_vampshifter(mtmp))
&& mon_in_room(mtmp, MORGUE)) {
const hallu = Hallucination() ? 1 : 0;
const hair = body_part(HAIR);
switch (rn2(2) + hallu) {
case 0: await You('suddenly realize it is unnaturally quiet.'); break;
case 1:
await pline_The(`${hair} on the back of your ${body_part(NECK)} ${vtense(hair, 'stand')} up.`);
break;
case 2:
await pline_The(`${hair} on your ${body_part(HEAD)} ${vtense(hair, 'seem')} to stand up.`);
break;
}
return true;
}
return false;
}
// C ref: sounds.c:114 zoo_mon_sound — RNG: rn2
async function zoo_mon_sound(mtmp) {
if (!mtmp?.data) return false;
if ((mtmp.msleeping || is_animal(mtmp.data))
&& mon_in_room(mtmp, ZOO)) {
const hallu = Hallucination() ? 1 : 0;
const selection = rn2(2) + hallu;
const zoo_msg = [
'a sound reminiscent of an elephant stepping on a peanut.',
'a sound reminiscent of a seal barking.',
'Doctor Dolittle!',
];
await You_hear(zoo_msg[selection]);
return true;
}
return false;
}
// C ref: sounds.c:130 temple_priest_sound — RNG: rn2
async function temple_priest_sound(mtmp) {
if (mtmp.ispriest && inhistemple(mtmp)
&& !helpless(mtmp)
&& temple_occupied(game.u?.urooms ?? '') !== EPRI(mtmp)?.shroom) {
const temple_msg = [
'*someone praising %s.', '*someone beseeching %s.',
'#an animal carcass being offered in sacrifice.',
'*a strident plea for donations.',
];
const hallu = Hallucination() ? 1 : 0;
let trycount = 0;
const ax = EPRI(mtmp)?.shrpos?.x ?? mtmp.mx;
const ay = EPRI(mtmp)?.shrpos?.y ?? mtmp.my;
const speechless = (mtmp.data.msound <= MS_ANIMAL);
const in_sight = canseemon(mtmp) || cansee(ax, ay);
let msg;
do {
msg = temple_msg[rn2(temple_msg.length - 1 + hallu)];
if (msg.includes('*') && speechless)
continue;
if (msg.includes('#') && in_sight)
continue;
break;
} while (++trycount < 50);
// skip control flags
while (msg.length > 0 && !/[a-zA-Z]/.test(msg[0]))
msg = msg.substring(1);
if (msg.includes('%s')) {
await You_hear(msg.replace('%s', halu_gname(EPRI(mtmp)?.shralign ?? 0)));
} else {
await You_hear(msg);
}
return true;
}
return false;
}
// C ref: sounds.c:180 oracle_sound — RNG: rn2
async function oracle_sound(mtmp) {
if (!mtmp?.data) return false;
if (mtmp.data !== mons[PM_ORACLE])
return false;
// don't produce silly effects when she's clearly visible
if (Hallucination() || !canseemon(mtmp)) {
const hallu = Hallucination() ? 1 : 0;
const ora_msg = [
'a strange wind.', 'convulsive ravings.', 'snoring snakes.',
'someone say "No more woodchucks!"', 'a loud ZOT!',
];
await You_hear(ora_msg[rn2(3) + hallu * 2]);
}
return true;
}
// C ref: sounds.c:201 dosounds — RNG: rn2 (many calls)
export async function dosounds() {
if (Deaf() || !game.flags?.acoustics || game.u?.uswallow || Underwater())
return;
const hallu = Hallucination() ? 1 : 0;
const lflags = game.level?.flags ?? {};
if (lflags.nfountains && !rn2(400)) {
const fountain_msg = ['bubbling water.', 'water falling on coins.',
'the splashing of a naiad.', 'a soda fountain!'];
await You_hear(fountain_msg[rn2(3) + hallu]);
}
if (lflags.nsinks && !rn2(300)) {
const sink_msg = ['a slow drip.', 'a gurgling noise.', 'dishes being washed!'];
await You_hear(sink_msg[rn2(2) + hallu]);
}
if (lflags.has_court && !rn2(200)) {
for (let m = game.level?.monlist; m; m = m.nmon) {
if (m.mhp > 0 && await throne_mon_sound(m)) return;
}
}
if (lflags.has_swamp && !rn2(200)) {
const swamp_msg = ['hear mosquitoes!', 'smell marsh gas!', 'hear Donald Duck!'];
await You(swamp_msg[rn2(2) + hallu]);
return;
}
if (lflags.has_vault && !rn2(200)) {
const sroom = search_special(VAULT);
if (!sroom) {
lflags.has_vault = 0;
return;
}
if (gd_sound()) {
const rval = rn2(2) + hallu;
switch (rval) {
case 1: {
let gold_in_vault = false;
for (let vx = sroom.lx; vx <= sroom.hx; vx++)
for (let vy = sroom.ly; vy <= sroom.hy; vy++)
if (g_at(vx, vy))
gold_in_vault = true;
const roomIdx = game.level.rooms.indexOf(sroom);
if (vault_occupied(game.u?.urooms ?? '')
!== (roomIdx + ROOMOFFSET)) {
if (gold_in_vault) {
await You_hear(!hallu
? 'someone counting gold coins.'
: 'the quarterback calling the play.');
} else {
await You_hear('someone searching.');
}
break;
}
}
// FALLTHROUGH
// falls through
case 0:
await You_hear('the footsteps of a guard on patrol.');
break;
case 2:
await You_hear('Ebenezer Scrooge!');
break;
}
}
return;
}
if (lflags.has_beehive && !rn2(200)) {
for (let m = game.level?.monlist; m; m = m.nmon) {
if (m.mhp > 0 && await beehive_mon_sound(m)) return;
}
}
if (lflags.has_morgue && !rn2(200)) {
for (let m = game.level?.monlist; m; m = m.nmon) {
if (m.mhp > 0 && await morgue_mon_sound(m)) return;
}
}
if (lflags.has_barracks && !rn2(200)) {
const barracks_msg = [
'blades being honed.', 'loud snoring.',
'dice being thrown.', 'General MacArthur!',
];
let count = 0;
for (let mtmp = game.level?.monlist; mtmp; mtmp = mtmp.nmon) {
if (mtmp.mhp <= 0) continue;
if (is_mercenary(mtmp.data)
&& mon_in_room(mtmp, BARRACKS)
&& (mtmp.msleeping || ++count > 5)) {
await You_hear(barracks_msg[rn2(3) + hallu]);
return;
}
}
}
if (lflags.has_zoo && !rn2(200)) {
for (let m = game.level?.monlist; m; m = m.nmon) {
if (m.mhp > 0 && await zoo_mon_sound(m)) return;
}
}
if (lflags.has_shop && !rn2(200)) {
const sroom = search_special(ANY_SHOP);
if (!sroom) {
lflags.has_shop = 0;
return;
}
const roomIdx = game.level.rooms.indexOf(sroom);
if (tended_shop(sroom)
&& !(game.u?.ushops ?? '').includes(String.fromCharCode(roomIdx + ROOMOFFSET))) {
const shop_msg = [
'someone cursing shoplifters.',
'the chime of a cash register.', 'Neiman and Marcus arguing!',
];
await You_hear(shop_msg[rn2(2) + hallu]);
noisy_shop(sroom);
}
return;
}
if (lflags.has_temple && !rn2(200)
&& !(Is_astralevel(game.u?.uz) || Is_sanctum(game.u?.uz))) {
for (let m = game.level?.monlist; m; m = m.nmon) {
if (m.mhp > 0 && await temple_priest_sound(m)) return;
}
}
if (Is_oracle_level(game.u?.uz) && !rn2(400)) {
for (let m = game.level?.monlist; m; m = m.nmon) {
if (m.mhp > 0 && await oracle_sound(m)) return;
}
}
}
// C ref: sounds.c:350 growl_sound
export function growl_sound(mtmp) {
if (!mtmp?.data) return 'scream';
switch (mtmp.data.msound) {
case MS_MEW: case MS_HISS: return 'hiss';
case MS_BARK: case MS_GROWL: return 'growl';
case MS_ROAR: return 'roar';
case MS_BELLOW: return 'bellow';
case MS_BUZZ: return 'buzz';
case MS_SQEEK: return 'squeal';
case MS_SQAWK: return 'screech';
case MS_NEIGH: return 'neigh';
case MS_WAIL: return 'wail';
case MS_GROAN: return 'groan';
case MS_MOO: return 'low';
case MS_SILENT: return 'commotion';
default: return 'scream';
}
}
// C ref: sounds.c:403 growl
export async function growl(mtmp) {
if (!mtmp?.data) return;
if (helpless(mtmp) || mtmp.data.msound === MS_SILENT)
return;
let growl_verb;
if (Hallucination())
growl_verb = ROLL_FROM(h_sounds);
else
growl_verb = growl_sound(mtmp);
if (growl_verb) {
if (canseemon(mtmp) || !Deaf()) {
await pline(`${Monnam(mtmp)} ${vtense(null, growl_verb)}!`);
game.iflags.last_msg = PLNMSG_GROWL;
if (game.context?.run)
nomul(0);
}
wake_nearto(mtmp.mx, mtmp.my, mtmp.data.mlevel * 18);
}
}
// C ref: sounds.c:428 yelp
export async function yelp(mtmp) {
if (!mtmp?.data) return;
if (helpless(mtmp) || !mtmp.data.msound)
return;
let yelp_verb;
if (Hallucination()) {
yelp_verb = ROLL_FROM(h_sounds);
} else {
switch (mtmp.data.msound) {
case MS_MEW:
yelp_verb = (!Deaf()) ? 'yowl' : 'arch';
break;
case MS_BARK:
case MS_GROWL:
yelp_verb = (!Deaf()) ? 'yelp' : 'recoil';
break;
case MS_ROAR:
yelp_verb = (!Deaf()) ? 'snarl' : 'flinch';
break;
case MS_BELLOW:
yelp_verb = (!Deaf()) ? 'snarl' : 'bluff';
break;
case MS_SQEEK:
yelp_verb = (!Deaf()) ? 'squeal' : 'quiver';
break;
case MS_SQAWK:
yelp_verb = (!Deaf()) ? 'screak' : 'thrash';
break;
case MS_WAIL:
yelp_verb = (!Deaf()) ? 'wail' : 'cringe';
break;
}
}
if (yelp_verb) {
await pline(`${Monnam(mtmp)} ${vtense(null, yelp_verb)}!`);
if (game.context?.run)
nomul(0);
wake_nearto(mtmp.mx, mtmp.my, mtmp.data.mlevel * 12);
}
}
// C ref: sounds.c:480 whimper
export async function whimper(mtmp) {
if (!mtmp?.data) return;
if (helpless(mtmp) || !mtmp.data.msound)
return;
let whimper_verb;
if (Hallucination()) {
whimper_verb = ROLL_FROM(h_sounds);
} else {
switch (mtmp.data.msound) {
case MS_MEW:
case MS_GROWL:
whimper_verb = 'whimper';
break;
case MS_BARK:
whimper_verb = 'whine';
break;
case MS_SQEEK:
whimper_verb = 'squeal';
break;
}
}
if (whimper_verb) {
await pline(`${Monnam(mtmp)} ${vtense(null, whimper_verb)}.`);
if (game.context?.run)
nomul(0);
wake_nearto(mtmp.mx, mtmp.my, mtmp.data.mlevel * 6);
}
}
// C ref: sounds.c:520 beg — pet makes "I'm hungry" noises
export async function beg(mtmp) {
if (!mtmp?.data) return;
if (helpless(mtmp)
|| !(carnivorous(mtmp.data) || herbivorous(mtmp.data)))
return;
if (!is_silent(mtmp.data) && mtmp.data.msound <= MS_ANIMAL) {
await domonnoise(mtmp);
} else if (mtmp.data.msound >= MS_HUMANOID) {
if (!canspotmon(mtmp))
map_invisible(mtmp.mx, mtmp.my);
SetVoice(mtmp, 0, 80, 0);
await verbalize("I'm hungry.");
} else {
if (canspotmon(mtmp))
await pline(`${Monnam(mtmp)} seems famished.`);
}
}
// C ref: sounds.c:545 maybe_gasp — hero attacked peaceful within mon's view
export function maybe_gasp(mon) {
const Exclam = ['Gasp!', 'Uh-oh.', 'Oh my!', 'What?', 'Why?'];
const mptr = mon.data;
let msound = mptr.msound;
let dogasp = false;
if ((msound === MS_GUARDIAN && mptr !== mons[game.urole?.guardnum])
|| (msound === MS_PRIEST && !p_coaligned(mon)))
msound = MS_SILENT;
else if (msound === MS_CUSS && has_emin(mon)
&& (p_coaligned(mon) ? !EMIN(mon).renegade : EMIN(mon).renegade))
msound = MS_HUMANOID;
switch (msound) {
case MS_HUMANOID:
case MS_ARREST:
case MS_SOLDIER:
case MS_GUARD:
case MS_NURSE:
case MS_SEDUCE:
case MS_LEADER:
case MS_GUARDIAN:
case MS_SELL:
case MS_ORACLE:
case MS_PRIEST:
case MS_BOAST:
case MS_IMITATE:
dogasp = true;
break;
case MS_ORC:
case MS_GRUNT:
case MS_LAUGH:
case MS_ROAR:
case MS_BELLOW:
case MS_DJINNI:
case MS_VAMPIRE:
case MS_WERE:
case MS_SPELL:
dogasp = (mptr.mlet === game.youmonst?.data?.mlet);
break;
case MS_BRIBE:
case MS_CUSS:
case MS_RIDER:
case MS_NEMESIS:
case MS_SILENT:
default:
break;
}
if (dogasp) {
return ROLL_FROM(Exclam);
}
return null;
}
// C ref: sounds.c:612 cry_sound — for egg hatching
export function cry_sound(mtmp) {
const ptr = mtmp.data;
switch (ptr.msound) {
default:
case MS_SILENT:
return (ptr.mlet === S_EEL) ? 'gurgle' : 'chitter';
case MS_HISS:
return 'hiss';
case MS_ROAR:
case MS_GROWL:
return 'growl';
case MS_CHIRP:
return 'chirp';
case MS_BUZZ:
return 'buzz';
case MS_SQAWK:
return 'screech';
case MS_GRUNT:
return 'grunt';
case MS_MUMBLE:
return 'mumble';
}
}
// C ref: sounds.c:658 mon_is_gecko
function mon_is_gecko(mon) {
if (mon.data === mons[PM_GECKO])
return true;
if (mon.data === mons[PM_LONG_WORM])
return false;
const glyph = glyph_at(mon.mx, mon.my);
return glyph_to_mon(glyph) === PM_GECKO;
}
// C ref: sounds.c:680 domonnoise — RNG: rn2 (many calls)
export async function domonnoise(mtmp) {
let pline_msg = null;
let verbl_msg = null;
let verbl_msg_mcan = null;
const ptr = mtmp.data;
let msound = ptr.msound;
let gnomeplan = 0;
if (Deaf())
return ECMD_OK;
if (is_silent(ptr) && !mtmp.isshk)
return ECMD_OK;
// leader might be poly'd
if (mtmp.m_id === game.quest_status?.leader_m_id && msound > MS_ANIMAL)
msound = MS_LEADER;
else if (msound === MS_GUARDIAN && ptr !== mons[game.urole?.guardnum])
msound = mons[genus(monsndx(ptr), 1)]?.msound ?? msound;
else if (mtmp.isshk)
msound = MS_SELL;
else if (msound === MS_ORC
&& ((same_race(ptr, game.youmonst?.data)
|| same_race(ptr, mons[game.u?.urace?.mnum ?? 0]))
|| Hallucination()))
msound = MS_HUMANOID;
else if (msound === MS_MOO && !mtmp.mtame)
msound = MS_BELLOW;
else if (Hallucination() && mon_is_gecko(mtmp))
msound = MS_SELL;
if (!canspotmon(mtmp))
map_invisible(mtmp.mx, mtmp.my);
switch (msound) {
case MS_ORACLE:
return doconsult(mtmp);
case MS_PRIEST:
await priest_talk(mtmp);
break;
case MS_LEADER:
case MS_NEMESIS:
case MS_GUARDIAN:
await quest_chat(mtmp);
break;
case MS_SELL:
if (!Hallucination() || is_silent(ptr) || (mtmp.isshk && !rn2(2))) {
await shk_chat(mtmp);
} else {
verbl_msg = `15 minutes could save you 15 ${currency(15)}.`;
}
break;
case MS_VAMPIRE: {
const isnight = night();
const kindred = (Upolyd() && (game.u.umonnum === PM_VAMPIRE
|| game.u.umonnum === PM_VAMPIRE_LEADER));
const nightchild = (Upolyd() && (game.u.umonnum === PM_WOLF
|| game.u.umonnum === PM_WINTER_WOLF
|| game.u.umonnum === PM_WINTER_WOLF_CUB));
const racenoun = (game.flags?.female && game.urace?.individual?.f)
? game.urace.individual.f
: (game.urace?.individual?.m)
? game.urace.individual.m
: game.urace?.noun ?? 'human';
if (mtmp.mtame) {
if (kindred) {
verbl_msg = `Good ${isnight ? 'evening' : 'day'} to you Master${isnight ? '!' : '. Why do we not rest?'}`;
} else {
verbl_msg = `${nightchild ? 'Child of the night, ' : ''}${
midnight()
? "I can stand this craving no longer!"
: isnight
? "I beg you, help me satisfy this growing craving!"
: "I find myself growing a little weary."}`;
}
} else if (mtmp.mpeaceful) {
if (kindred && isnight) {
verbl_msg = `Good feeding ${game.flags?.female ? 'sister' : 'brother'}!`;
} else if (nightchild && isnight) {
verbl_msg = 'How nice to hear you, child of the night!';
} else
verbl_msg = 'I only drink... potions.';
} else {
const vampmsg = [
'I vant to suck your %s!',
'I vill come after %s without regret!',
];
if (kindred) {
verbl_msg = 'This is my hunting ground that you dare to prowl!';
} else if (game.youmonst?.data === mons[PM_SILVER_DRAGON]
|| game.youmonst?.data === mons[PM_BABY_SILVER_DRAGON]) {
verbl_msg = `${(game.youmonst.data === mons[PM_SILVER_DRAGON])
? 'Fool' : 'Young Fool'}! Your silver sheen does not frighten me!`;
} else {
const vampindex = rn2(vampmsg.length);
if (vampindex === 0) {
verbl_msg = vampmsg[0].replace('%s', body_part(BLOOD));
} else if (vampindex === 1) {
verbl_msg = vampmsg[1].replace('%s',
Upolyd() ? an(pmname(mons[game.u.umonnum],
game.flags?.female ? 1 : 0))
: an(racenoun));
} else {
verbl_msg = vampmsg[vampindex];
}
}
}
break;
}
case MS_WERE:
if (game.flags?.moonphase === FULL_MOON && (night() ^ !rn2(13))) {
await pline(`${Monnam(mtmp)} throws back ${mhis(mtmp)} head and lets out a blood curdling ${
(ptr === mons[PM_HUMAN_WERERAT]) ? 'shriek' : 'howl'}!`);
wake_nearto(mtmp.mx, mtmp.my, 11 * 11);
} else {
pline_msg = 'whispers inaudibly. All you can make out is "moon".';
}
break;
case MS_BARK:
if (game.flags?.moonphase === FULL_MOON && night()) {
pline_msg = 'howls.';
} else if (mtmp.mpeaceful) {
if (mtmp.mtame
&& (mtmp.mconf || mtmp.mflee || mtmp.mtrapped
|| game.moves > EDOG(mtmp)?.hungrytime || mtmp.mtame < 5))
pline_msg = 'whines.';
else if (mtmp.mtame && EDOG(mtmp)?.hungrytime > game.moves + 1000)
pline_msg = 'yips.';
else {
if (ptr !== mons[PM_DINGO])
pline_msg = 'barks.';
}
} else {
pline_msg = 'growls.';
}
break;
case MS_MEW:
if (mtmp.mtame) {
if (mtmp.mconf || mtmp.mflee || mtmp.mtrapped
|| mtmp.mtame < 5) {
pline_msg = 'yowls.';
} else if (game.moves > EDOG(mtmp)?.hungrytime) {
pline_msg = 'meows.';
} else if (EDOG(mtmp)?.hungrytime > game.moves + 1000) {
pline_msg = 'purrs.';
} else {
pline_msg = 'mews.';
}
break;
}
// FALLTHROUGH
// falls through
case MS_GROWL:
pline_msg = mtmp.mpeaceful ? 'snarls.' : 'growls!';
break;
case MS_ROAR:
pline_msg = mtmp.mpeaceful ? 'snarls.' : 'roars!';
break;
case MS_SQEEK:
pline_msg = 'squeaks.';
break;
case MS_SQAWK:
if (ptr === mons[PM_RAVEN] && !mtmp.mpeaceful) {
verbl_msg = 'Nevermore!';
} else {
pline_msg = 'squawks.';
}
break;
case MS_HISS:
if (!mtmp.mpeaceful) {
pline_msg = 'hisses!';
} else {
return ECMD_OK;
}
break;
case MS_BUZZ:
pline_msg = mtmp.mpeaceful ? 'drones.' : 'buzzes angrily.';
break;
case MS_GRUNT:
pline_msg = 'grunts.';
break;
case MS_NEIGH:
if (mtmp.mtame < 5) {
pline_msg = 'neighs.';
} else if (game.moves > EDOG(mtmp)?.hungrytime) {
pline_msg = 'whinnies.';
} else {
pline_msg = 'whickers.';
}
break;
case MS_MOO:
pline_msg = 'moos.';
break;
case MS_BELLOW:
pline_msg = 'bellows!';
break;
case MS_CHIRP:
pline_msg = 'chirps.';
break;
case MS_WAIL:
pline_msg = 'wails mournfully.';
break;
case MS_GROAN:
if (!rn2(3)) {
pline_msg = 'groans.';
}
break;
case MS_GURGLE:
pline_msg = 'gurgles.';
break;
case MS_BURBLE:
pline_msg = 'burbles.';
break;
case MS_TRUMPET:
pline_msg = 'trumpets!';
wake_nearto(mtmp.mx, mtmp.my, 11 * 11);
break;
case MS_SHRIEK:
pline_msg = 'shrieks.';
aggravate();
break;
case MS_IMITATE:
pline_msg = 'imitates you.';
break;
case MS_BONES:
await pline(`${Monnam(mtmp)} rattles noisily.`);
await You('freeze for a moment.');
nomul(-2);
game.multi_reason = 'scared by rattling';
game.nomovemsg = 0;
break;
case MS_LAUGH: {
const laugh_msg = ['giggles.', 'chuckles.', 'snickers.', 'laughs.'];
pline_msg = laugh_msg[rn2(4)];
break;
}
case MS_MUMBLE:
pline_msg = 'mumbles incomprehensibly.';
break;
case MS_ORC:
pline_msg = 'grunts.';
break;
case MS_DJINNI:
if (mtmp.mtame) {
verbl_msg = "Sorry, I'm all out of wishes.";
} else if (mtmp.mpeaceful) {
if (ptr === mons[PM_WATER_DEMON])
pline_msg = 'gurgles.';
else
verbl_msg = "I'm free!";
} else {
if (ptr !== mons[PM_PRISONER])
verbl_msg = 'This will teach you not to disturb me!';
else
verbl_msg = 'Get me out of here.';
}
break;
case MS_BOAST:
if (!mtmp.mpeaceful) {
switch (rn2(4)) {
case 0:
await pline(`${Monnam(mtmp)} boasts about ${mhis(mtmp)} gem collection.`);
break;
case 1:
pline_msg = 'complains about a diet of mutton.';
break;
default:
pline_msg = 'shouts "Fee Fie Foe Foo!" and guffaws.';
wake_nearto(mtmp.mx, mtmp.my, 7 * 7);
break;
}
break;
}
// FALLTHROUGH
// falls through
case MS_HUMANOID:
if (!mtmp.mpeaceful) {
if (In_endgame(game.u?.uz) && is_mplayer(ptr))
await mplayer_talk(mtmp);
else
pline_msg = 'threatens you.';
break;
}
if (mtmp.mflee)
pline_msg = 'wants nothing to do with you.';
else if (mtmp.mhp < Math.trunc(mtmp.mhpmax / 4))
pline_msg = 'moans.';
else if (mtmp.mconf || mtmp.mstun)
verbl_msg = !rn2(3) ? 'Huh?' : rn2(2) ? 'What?' : 'Eh?';
else if (!mtmp.mcansee)
verbl_msg = "I can't see!";
else if (mtmp.mtrapped) {
const t = t_at(mtmp.mx, mtmp.my);
if (t) t.tseen = 1;
verbl_msg = "I'm trapped!";
} else if (mtmp.mhp < Math.trunc(mtmp.mhpmax / 2))
pline_msg = 'asks for a potion of healing.';
else if (mtmp.mtame && !mtmp.isminion
&& game.moves > EDOG(mtmp)?.hungrytime)
verbl_msg = "I'm hungry.";
else if (is_elf(ptr))
pline_msg = 'curses orcs.';
else if (is_dwarf(ptr))
pline_msg = 'talks about mining.';
else if (likes_magic(ptr))
pline_msg = 'talks about spellcraft.';
else if (ptr.mlet === S_CENTAUR)
pline_msg = 'discusses hunting.';
else if (is_gnome(ptr)) {
if (Hallucination() && (gnomeplan = rn2(4)) % 2) {
verbl_msg = (gnomeplan === 1)
? 'Phase one, collect underpants.'
: 'Phase three, profit!';
} else {
verbl_msg = 'Many enter the dungeon, and few return to the sunlit lands.';
}
} else {
switch (monsndx(ptr)) {
case PM_HOBBIT:
pline_msg = (mtmp.mhp < mtmp.mhpmax
&& (mtmp.mhpmax <= 10
|| mtmp.mhp <= mtmp.mhpmax - 10))
? 'complains about unpleasant dungeon conditions.'
: 'asks you about the One Ring.';
break;
case PM_ARCHEOLOGIST:
pline_msg = 'describes a recent article in "Spelunker Today" magazine.';
break;
case PM_TOURIST:
verbl_msg = 'Aloha.';
break;
default:
pline_msg = 'discusses dungeon exploration.';
break;
}
}
break;
case MS_SEDUCE: {
let swval;
if (SYSOPT_SEDUCE()) {
if (ptr.mlet !== S_NYMPH
&& (could_seduce(mtmp, game.youmonst, null) === 1)) {
await doseduce(mtmp);
break;
}
swval = ((poly_gender() !== (mtmp.female ? 1 : 0)) ? rn2(3) : 0);
} else {
swval = ((poly_gender() === 0) ? rn2(3) : 0);
}
switch (swval) {
case 2:
verbl_msg = 'Hello, sailor.';
break;
case 1:
pline_msg = 'comes on to you.';
break;
default:
pline_msg = 'cajoles you.';
}
break;
}
case MS_ARREST:
if (mtmp.mpeaceful) {
SetVoice(mtmp, 0, 80, 0);
await verbalize(`Just the facts, ${game.flags?.female ? "Ma'am" : 'Sir'}.`);
} else {
const arrest_msg = [
'Anything you say can be used against you.',
"You're under arrest!", 'Stop in the name of the Law!',
];
verbl_msg = arrest_msg[rn2(3)];
}
break;
case MS_BRIBE:
if (mtmp.mpeaceful && !mtmp.mtame) {
await demon_talk(mtmp);
break;
}
// FALLTHROUGH
// falls through
case MS_CUSS:
if (!mtmp.mpeaceful)
await cuss(mtmp);
else if (is_lminion(mtmp))
verbl_msg = "It's not too late.";
else
verbl_msg = "We're all doomed.";
break;
case MS_SPELL:
pline_msg = 'seems to mutter a cantrip.';
break;
case MS_NURSE:
verbl_msg_mcan = 'I hate this job!';
if (game.u.uwep && (game.u.uwep.oclass === WEAPON_CLASS || is_weptool(game.u.uwep)))
verbl_msg = 'Put that weapon away before you hurt someone!';
else if (game.u.uarmc || game.u.uarm || game.u.uarmh || game.u.uarms || game.u.uarmg || game.u.uarmf)
verbl_msg = Role_if('Healer')
? "Doc, I can't help you unless you cooperate."
: 'Please undress so I can examine you.';
else if (game.u.uarmu)
verbl_msg = 'Take off your shirt, please.';
else
verbl_msg = "Relax, this won't hurt a bit.";
break;
case MS_GUARD:
if (money_cnt(game.invent))
verbl_msg = 'Please drop that gold and follow me.';
else
verbl_msg = 'Please follow me.';
break;
case MS_SOLDIER: {
const soldier_foe_msg = [
'Resistance is useless!', "You're dog meat!", 'Surrender!',
];
const soldier_pax_msg = [
"What lousy pay we're getting here!",
"The food's not fit for Orcs!",
"My feet hurt, I've been on them all day!",
];
verbl_msg = mtmp.mpeaceful ? soldier_pax_msg[rn2(3)]
: soldier_foe_msg[rn2(3)];
break;
}
case MS_RIDER: {
const ms_Death = (ptr === mons[PM_DEATH]);
if (ms_Death && !game.context?.tribute?.Deathnotice) {
const book = u_have_novel();
if (book) {
const tribtitle = noveltitle(book.novelidx);
if (tribtitle) {
verbl_msg = `Ah, so you have a copy of /${tribtitle}/. I may have been misquoted there.`;
game.context.tribute.Deathnotice = 1;
}
}
}
if (!verbl_msg && ms_Death && rn2(3) && Death_quote()) {
verbl_msg = 'Who do you think you are, War?'; // placeholder
}
if (!verbl_msg) {
if (ms_Death && !rn2(10)) {
pline_msg = 'is busy reading a copy of Sandman #8.';
} else {
verbl_msg = 'Who do you think you are, War?';
}
}
break;
}
} // switch
if (pline_msg) {
await pline(`${Monnam(mtmp)} ${pline_msg}`);
} else if (mtmp.mcan && verbl_msg_mcan) {
SetVoice(mtmp, 0, 80, 0);
await verbalize(verbl_msg_mcan);
} else if (verbl_msg) {
if (ptr === mons[PM_DEATH]) {
// Death talks in CAPITAL LETTERS without quotation marks
await pline(ucase(verbl_msg));
SetVoice(null, 0, 80, 0);
} else {
SetVoice(mtmp, 0, 80, 0);
await verbalize(verbl_msg);
}
}
return ECMD_TIME;
}
// C ref: sounds.c:1248 dotalk — #chat command
export async function dotalk() {
const result = await dochat();
return result;
}
// C ref: sounds.c:1412 responsive_mon_at
// responsive_mon_at: imported from mon.js
async function dochat() {
let mtmp;
let tx, ty;
if (is_silent(game.youmonst?.data)) {
await pline(`As ${an(pmname(game.youmonst.data, game.flags?.female ? 1 : 0))}, you cannot speak.`);
return ECMD_OK;
}
if (Strangled()) {
await You_cant("speak. You're choking!");
return ECMD_OK;
}
if (game.u?.uswallow) {
await pline("They won't hear you out there.");
return ECMD_OK;
}
if (Underwater()) {
await Your('speech is unintelligible underwater.');
return ECMD_OK;
}
if (!Deaf() && !Blind()) {
const otmp = shop_object(game.u.ux, game.u.uy);
if (otmp) {
price_quote(otmp);
return ECMD_TIME;
}
}
if (!await getdir('Talk to whom? (in what direction)')) {
return ECMD_CANCEL;
}
if (game.u.usteed && game.u.dz > 0) {
if (helpless(game.u.usteed)) {
await pline(`${Monnam(game.u.usteed)} seems not to notice you.`);
return ECMD_TIME;
} else
return await domonnoise(game.u.usteed);
}
if (game.u.dz) {
await pline(`They won't hear you ${game.u.dz < 0 ? 'up' : 'down'} there.`);
return ECMD_OK;
}
if (game.u.dx === 0 && game.u.dy === 0) {
await pline('Talking to yourself is a bad habit for a dungeoneer.');
return ECMD_OK;
}
tx = game.u.ux + game.u.dx;
ty = game.u.uy + game.u.dy;
if (!isok(tx, ty))
return ECMD_OK;
mtmp = m_at(tx, ty);
if (!mtmp || mtmp.mundetected) {
const otmp = vobj_at(tx, ty);
if (otmp && otmp.otyp === STATUE) { // TODO: use STATUE constant
if (!Blind())
await pline_The(`${Hallucination() ? rndmonnam() : 'statue'} seems not to notice you.`);
return ECMD_OK;
}
const levl_at = game.level?.at(tx, ty);
if (!Deaf() && levl_at && (IS_WALL(levl_at.typ) || levl_at.typ === SDOOR)) {
if (Blind() && false /* !IS_WALL(lastseentyp[tx][ty]) */) {
// when blind, can only talk to wall if already mapped as wall
} else if (!Hallucination()) {
await pline("It's like talking to a wall.");
} else {
const walltalk = [
'gripes about its job.',
'tells you a funny joke!',
'insults your heritage!',
'chuckles.',
'guffaws merrily!',
'deprecates your exploration efforts.',
'suggests a stint of rehab...',
"doesn't seem to be interested.",
];
let idx = rn2(10);
if (idx >= walltalk.length)
idx = walltalk.length - 1;
await pline_The(`wall ${walltalk[idx]}`);
}
return ECMD_OK;
}
}
if (!mtmp || mtmp.mundetected
|| M_AP_TYPE(mtmp) === M_AP_FURNITURE
|| M_AP_TYPE(mtmp) === M_AP_OBJECT)
return ECMD_OK;
// sleeping monsters won't talk, except priests (who wake up)
if (helpless(mtmp) && !mtmp.ispriest) {
if (canspotmon(mtmp))
await pline(`${Monnam(mtmp)} seems not to notice you.`);
return ECMD_OK;
}
// prod monster into action
mtmp.mstrategy &= ~STRAT_WAITMASK;
if (!Deaf() && mtmp.mtame && mtmp.meating) {
if (!canspotmon(mtmp))
map_invisible(mtmp.mx, mtmp.my);
await pline(`${Monnam(mtmp)} is eating noisily.`);
return ECMD_OK;
}
if (Deaf()) {
const xresponse = humanoid(game.youmonst?.data)
? 'falls on deaf ears'
: 'is inaudible';
await pline(`Any response${canspotmon(mtmp) ? ' from ' : ''}${canspotmon(mtmp) ? mon_nam(mtmp) : ''} ${xresponse}.`);
return ECMD_OK;
}
return await domonnoise(mtmp);
}
// C ref: sounds.c:1426 tiphat — #tip hat at monster
export async function tiphat() {
let mtmp;
if (!game.u.uarmh) return 0;
let res = game.u.uarmh.bknown ? 0 : 1;
if (game.u.uarmh.cursed) {
await You_cant("It is cursed.");
return res;
}
if (!await getdir('At whom? (in what direction)'))
return res;
res = 1;
await You(`briefly doff your ${helm_simple_name(game.u.uarmh)}.`);
if (!game.u.dx && !game.u.dy) {
if (game.u.usteed && game.u.dz > 0) {
if (helpless(game.u.usteed))
await pline(`${Monnam(game.u.usteed)} doesn't notice.`);
else
await domonnoise(game.u.usteed);
} else if (game.u.dz) {
await pline(`There's no one ${(game.u.dz < 0) ? 'up' : 'down'} there.`);
} else {
await pline_The("lout here doesn't acknowledge you...");
}
return res;
}
mtmp = null;
let vismon = 0, unseen = 0, statue = 0, glyph = 0;
let x = game.u.ux, y = game.u.uy;
for (let range = 1; range <= BOLT_LIM + 1; ++range) {
x += game.u.dx;
y += game.u.dy;
if (!isok(x, y) || (range > 1 && !couldsee(x, y))) {
x -= game.u.dx;
y -= game.u.dy;
break;
}
mtmp = m_at(x, y);
vismon = (mtmp && canseemon(mtmp)) ? 1 : 0;
glyph = glyph_at(x, y);
unseen = glyph_is_invisible(glyph) ? 1 : 0;
const otmp = vobj_at(x, y);
statue = (glyph_is_statue(glyph)
|| (!vismon && !unseen && otmp && otmp.otyp === STATUE)) ? 1 : 0;
if (vismon && (M_AP_TYPE(mtmp) === M_AP_FURNITURE
|| M_AP_TYPE(mtmp) === M_AP_OBJECT))
vismon = 0, mtmp = null;
if (vismon || unseen || (statue && Hallucination())
|| (range === 1 && mtmp && responsive_mon_at(x, y)
&& !is_silent(mtmp.data))
|| !(accessible(x, y) || (game.level?.at(x, y)?.typ === 11 /* IRONBARS */)))
break;
}
if (unseen || (statue && Hallucination())) {
await pline(`That ${unseen ? 'unseen ' : ''}creature is ignoring you!`);
} else if (!mtmp || !responsive_mon_at(x, y)) {
if (vismon)
await pline(`${Monnam(mtmp)} seems not to notice you.`);
else
await pline('Nothing happens.');
} else {
mtmp.mstrategy &= ~STRAT_WAITMASK;
if (vismon && humanoid(mtmp.data) && mtmp.mpeaceful && !Conflict()) {
const otmp = which_armor(mtmp, W_ARMH);
if (!otmp) {
await pline(`${Monnam(mtmp)} waves.`);
} else if (otmp.cursed) {
await pline(`${Monnam(mtmp)} grasps ${mhis(mtmp)} ${helm_simple_name(otmp)} but can't remove it.`);
otmp.bknown = 1;
} else {
await pline(`${Monnam(mtmp)} tips ${mhis(mtmp)} ${helm_simple_name(otmp)} in response.`);
}
} else if (vismon && humanoid(mtmp.data)) {
const reaction = ['curses', 'gestures rudely', 'gestures offensively'];
const which = !Deaf() ? rn2(3) : rn1(2, 1);
const twice = (Deaf() || which > 0 || rn2(3)) ? 0 : rn1(2, 1);
await pline(`${Monnam(mtmp)} ${reaction[which]}${twice ? ' and ' : ''}${twice ? reaction[twice] : ''} at you...`);
} else if (next2u(x, y) && !Deaf() && await domonnoise(mtmp)) {
if (!vismon)
map_invisible(x, y);
} else if (vismon) {
await pline(`${Monnam(mtmp)} doesn't respond.`);
} else {
await pline('Nothing happens.');
}
}
return res;
}
// Canonical stubs — duplicated in 18+ files
export function Soundeffect(seid, vol) { /* no-op in JS — no sound system */ }
export function SetVoice(mon, seid, vol, cap) { /* no-op */ }
|