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 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512
|
/* SCCS Id: @(#)uhitm.c 3.4 2003/02/18 */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
STATIC_DCL boolean FDECL(known_hitum, (struct monst *,int *,struct attack *));
STATIC_DCL void FDECL(steal_it, (struct monst *, struct attack *));
STATIC_DCL boolean FDECL(hitum, (struct monst *,int,struct attack *));
STATIC_DCL boolean FDECL(hmon_hitmon, (struct monst *,struct obj *,int));
#ifdef STEED
STATIC_DCL int FDECL(joust, (struct monst *,struct obj *));
#endif
STATIC_DCL void NDECL(demonpet);
STATIC_DCL boolean FDECL(m_slips_free, (struct monst *mtmp,struct attack *mattk));
STATIC_DCL int FDECL(explum, (struct monst *,struct attack *));
STATIC_DCL void FDECL(start_engulf, (struct monst *));
STATIC_DCL void NDECL(end_engulf);
STATIC_DCL int FDECL(gulpum, (struct monst *,struct attack *));
STATIC_DCL boolean FDECL(hmonas, (struct monst *,int));
STATIC_DCL void FDECL(nohandglow, (struct monst *));
STATIC_DCL boolean FDECL(shade_aware, (struct obj *));
extern boolean notonhead; /* for long worms */
/* The below might become a parameter instead if we use it a lot */
static int dieroll;
/* Used to flag attacks caused by Stormbringer's maliciousness. */
static boolean override_confirmation = FALSE;
#define PROJECTILE(obj) ((obj) && is_ammo(obj))
/* modified from hurtarmor() in mhitu.c */
/* This is not static because it is also used for monsters rusting monsters */
void
hurtmarmor(mdef, attk)
struct monst *mdef;
int attk;
{
int hurt;
struct obj *target;
switch(attk) {
/* 0 is burning, which we should never be called with */
case AD_RUST: hurt = 1; break;
case AD_CORR: hurt = 3; break;
default: hurt = 2; break;
}
/* What the following code does: it keeps looping until it
* finds a target for the rust monster.
* Head, feet, etc... not covered by metal, or covered by
* rusty metal, are not targets. However, your body always
* is, no matter what covers it.
*/
while (1) {
switch(rn2(5)) {
case 0:
target = which_armor(mdef, W_ARMH);
if (!target || !rust_dmg(target, xname(target), hurt, FALSE, mdef))
continue;
break;
case 1:
target = which_armor(mdef, W_ARMC);
if (target) {
(void)rust_dmg(target, xname(target), hurt, TRUE, mdef);
break;
}
if ((target = which_armor(mdef, W_ARM)) != (struct obj *)0) {
(void)rust_dmg(target, xname(target), hurt, TRUE, mdef);
#ifdef TOURIST
} else if ((target = which_armor(mdef, W_ARMU)) != (struct obj *)0) {
(void)rust_dmg(target, xname(target), hurt, TRUE, mdef);
#endif
}
break;
case 2:
target = which_armor(mdef, W_ARMS);
if (!target || !rust_dmg(target, xname(target), hurt, FALSE, mdef))
continue;
break;
case 3:
target = which_armor(mdef, W_ARMG);
if (!target || !rust_dmg(target, xname(target), hurt, FALSE, mdef))
continue;
break;
case 4:
target = which_armor(mdef, W_ARMF);
if (!target || !rust_dmg(target, xname(target), hurt, FALSE, mdef))
continue;
break;
}
break; /* Out of while loop */
}
}
/* FALSE means it's OK to attack */
boolean
attack_checks(mtmp, wep)
register struct monst *mtmp;
struct obj *wep; /* uwep for attack(), null for kick_monster() */
{
char qbuf[QBUFSZ];
/* if you're close enough to attack, alert any waiting monster */
mtmp->mstrategy &= ~STRAT_WAITMASK;
if (u.uswallow && mtmp == u.ustuck) return FALSE;
if (flags.forcefight) {
/* Do this in the caller, after we checked that the monster
* didn't die from the blow. Reason: putting the 'I' there
* causes the hero to forget the square's contents since
* both 'I' and remembered contents are stored in .glyph.
* If the monster dies immediately from the blow, the 'I' will
* not stay there, so the player will have suddenly forgotten
* the square's contents for no apparent reason.
if (!canspotmon(mtmp) &&
!glyph_is_invisible(levl[u.ux+u.dx][u.uy+u.dy].glyph))
map_invisible(u.ux+u.dx, u.uy+u.dy);
*/
return FALSE;
}
/* Put up an invisible monster marker, but with exceptions for
* monsters that hide and monsters you've been warned about.
* The former already prints a warning message and
* prevents you from hitting the monster just via the hidden monster
* code below; if we also did that here, similar behavior would be
* happening two turns in a row. The latter shows a glyph on
* the screen, so you know something is there.
*/
if (!canspotmon(mtmp) &&
!glyph_is_warning(glyph_at(u.ux+u.dx,u.uy+u.dy)) &&
!glyph_is_invisible(levl[u.ux+u.dx][u.uy+u.dy].glyph) &&
!(!Blind && mtmp->mundetected && hides_under(mtmp->data))) {
pline("Wait! There's %s there you can't see!",
something);
map_invisible(u.ux+u.dx, u.uy+u.dy);
/* if it was an invisible mimic, treat it as if we stumbled
* onto a visible mimic
*/
if(mtmp->m_ap_type && !Protection_from_shape_changers) {
if(!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data,AD_STCK))
u.ustuck = mtmp;
}
wakeup(mtmp); /* always necessary; also un-mimics mimics */
return TRUE;
}
if (mtmp->m_ap_type && !Protection_from_shape_changers &&
!sensemon(mtmp) &&
!glyph_is_warning(glyph_at(u.ux+u.dx,u.uy+u.dy))) {
/* If a hidden mimic was in a square where a player remembers
* some (probably different) unseen monster, the player is in
* luck--he attacks it even though it's hidden.
*/
if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) {
seemimic(mtmp);
return(FALSE);
}
stumble_onto_mimic(mtmp);
return TRUE;
}
if (mtmp->mundetected && !canseemon(mtmp) &&
!glyph_is_warning(glyph_at(u.ux+u.dx,u.uy+u.dy)) &&
(hides_under(mtmp->data) || mtmp->data->mlet == S_EEL)) {
mtmp->mundetected = mtmp->msleeping = 0;
newsym(mtmp->mx, mtmp->my);
if (glyph_is_invisible(levl[mtmp->mx][mtmp->my].glyph)) {
seemimic(mtmp);
return(FALSE);
}
if (!(Blind ? Blind_telepat : Unblind_telepat)) {
struct obj *obj;
if (Blind || (is_pool(mtmp->mx,mtmp->my) && !Underwater))
pline("Wait! There's a hidden monster there!");
else if ((obj = level.objects[mtmp->mx][mtmp->my]) != 0)
pline("Wait! There's %s hiding under %s!",
an(l_monnam(mtmp)), doname(obj));
return TRUE;
}
}
/*
* make sure to wake up a monster from the above cases if the
* hero can sense that the monster is there.
*/
if ((mtmp->mundetected || mtmp->m_ap_type) && sensemon(mtmp)) {
mtmp->mundetected = 0;
wakeup(mtmp);
}
if (flags.confirm && mtmp->mpeaceful
&& !Confusion && !Hallucination && !Stunned) {
/* Intelligent chaotic weapons (Stormbringer) want blood */
if (wep && wep->oartifact == ART_STORMBRINGER) {
override_confirmation = TRUE;
return(FALSE);
}
if (canspotmon(mtmp)) {
Sprintf(qbuf, "Really attack %s?", mon_nam(mtmp));
if (yn(qbuf) != 'y') {
flags.move = 0;
return(TRUE);
}
}
}
return(FALSE);
}
/*
* It is unchivalrous for a knight to attack the defenseless or from behind.
*/
void
check_caitiff(mtmp)
struct monst *mtmp;
{
if (Role_if(PM_KNIGHT) && u.ualign.type == A_LAWFUL &&
(!mtmp->mcanmove || mtmp->msleeping ||
(mtmp->mflee && !mtmp->mavenge)) &&
u.ualign.record > -10) {
You("caitiff!");
adjalign(-1);
}
}
schar
find_roll_to_hit(mtmp)
register struct monst *mtmp;
{
schar tmp;
int tmp2;
tmp = 1 + Luck + abon() + find_mac(mtmp) + u.uhitinc +
maybe_polyd(youmonst.data->mlevel, u.ulevel);
check_caitiff(mtmp);
/* attacking peaceful creatures is bad for the samurai's giri */
if (Role_if(PM_SAMURAI) && mtmp->mpeaceful &&
u.ualign.record > -10) {
You("dishonorably attack the innocent!");
adjalign(-1);
}
/* Adjust vs. (and possibly modify) monster state. */
if(mtmp->mstun) tmp += 2;
if(mtmp->mflee) tmp += 2;
if (mtmp->msleeping) {
mtmp->msleeping = 0;
tmp += 2;
}
if(!mtmp->mcanmove) {
tmp += 4;
if(!rn2(10)) {
mtmp->mcanmove = 1;
mtmp->mfrozen = 0;
}
}
if (is_orc(mtmp->data) && maybe_polyd(is_elf(youmonst.data),
Race_if(PM_ELF)))
tmp++;
if(Role_if(PM_MONK) && !Upolyd) {
if (uarm) {
Your("armor is rather cumbersome...");
tmp -= urole.spelarmr;
} else if (!uwep && !uarms) {
tmp += (u.ulevel / 3) + 2;
}
}
/* with a lot of luggage, your agility diminishes */
if ((tmp2 = near_capacity()) != 0) tmp -= (tmp2*2) - 1;
if (u.utrap) tmp -= 3;
/* Some monsters have a combination of weapon attacks and non-weapon
* attacks. It is therefore wrong to add hitval to tmp; we must add
* it only for the specific attack (in hmonas()).
*/
if (uwep && !Upolyd) {
tmp += hitval(uwep, mtmp);
tmp += weapon_hit_bonus(uwep);
}
return tmp;
}
/* try to attack; return FALSE if monster evaded */
/* u.dx and u.dy must be set */
boolean
attack(mtmp)
register struct monst *mtmp;
{
schar tmp;
register struct permonst *mdat = mtmp->data;
/* This section of code provides protection against accidentally
* hitting peaceful (like '@') and tame (like 'd') monsters.
* Protection is provided as long as player is not: blind, confused,
* hallucinating or stunned.
* changes by wwp 5/16/85
* More changes 12/90, -dkh-. if its tame and safepet, (and protected
* 07/92) then we assume that you're not trying to attack. Instead,
* you'll usually just swap places if this is a movement command
*/
/* Intelligent chaotic weapons (Stormbringer) want blood */
if (is_safepet(mtmp) && !flags.forcefight) {
if (!uwep || uwep->oartifact != ART_STORMBRINGER) {
/* there are some additional considerations: this won't work
* if in a shop or Punished or you miss a random roll or
* if you can walk thru walls and your pet cannot (KAA) or
* if your pet is a long worm (unless someone does better).
* there's also a chance of displacing a "frozen" monster.
* sleeping monsters might magically walk in their sleep.
*/
boolean foo = (Punished || !rn2(7) || is_longworm(mtmp->data)),
inshop = FALSE;
char *p;
for (p = in_rooms(mtmp->mx, mtmp->my, SHOPBASE); *p; p++)
if (tended_shop(&rooms[*p - ROOMOFFSET])) {
inshop = TRUE;
break;
}
if (inshop || foo ||
(IS_ROCK(levl[u.ux][u.uy].typ) &&
!passes_walls(mtmp->data))) {
char buf[BUFSZ];
monflee(mtmp, rnd(6), FALSE, FALSE);
Strcpy(buf, y_monnam(mtmp));
buf[0] = highc(buf[0]);
You("stop. %s is in the way!", buf);
return(TRUE);
} else if ((mtmp->mfrozen || (! mtmp->mcanmove)
|| (mtmp->data->mmove == 0)) && rn2(6)) {
pline("%s doesn't seem to move!", Monnam(mtmp));
return(TRUE);
} else return(FALSE);
}
}
/* possibly set in attack_checks;
examined in known_hitum, called via hitum or hmonas below */
override_confirmation = FALSE;
if (attack_checks(mtmp, uwep)) return(TRUE);
if (Upolyd) {
/* certain "pacifist" monsters don't attack */
if(noattacks(youmonst.data)) {
You("have no way to attack monsters physically.");
mtmp->mstrategy &= ~STRAT_WAITMASK;
goto atk_done;
}
}
if(check_capacity("You cannot fight while so heavily loaded."))
goto atk_done;
if (u.twoweap && !can_twoweapon())
untwoweapon();
if(unweapon) {
unweapon = FALSE;
if(flags.verbose) {
if(uwep)
You("begin bashing monsters with your %s.",
aobjnam(uwep, (char *)0));
else if (!cantwield(youmonst.data))
You("begin %sing monsters with your %s %s.",
Role_if(PM_MONK) ? "strik" : "bash",
uarmg ? "gloved" : "bare", /* Del Lamb */
makeplural(body_part(HAND)));
}
}
exercise(A_STR, TRUE); /* you're exercising muscles */
/* andrew@orca: prevent unlimited pick-axe attacks */
u_wipe_engr(3);
/* Is the "it died" check actually correct? */
if(mdat->mlet == S_LEPRECHAUN && !mtmp->mfrozen && !mtmp->msleeping &&
!mtmp->mconf && mtmp->mcansee && !rn2(7) &&
(m_move(mtmp, 0) == 2 || /* it died */
mtmp->mx != u.ux+u.dx || mtmp->my != u.uy+u.dy)) /* it moved */
return(FALSE);
tmp = find_roll_to_hit(mtmp);
if (Upolyd)
(void) hmonas(mtmp, tmp);
else
(void) hitum(mtmp, tmp, youmonst.data->mattk);
mtmp->mstrategy &= ~STRAT_WAITMASK;
atk_done:
/* see comment in attack_checks() */
/* we only need to check for this if we did an attack_checks()
* and it returned 0 (it's okay to attack), and the monster didn't
* evade.
*/
if (flags.forcefight && mtmp->mhp > 0 && !canspotmon(mtmp) &&
!glyph_is_invisible(levl[u.ux+u.dx][u.uy+u.dy].glyph) &&
!(u.uswallow && mtmp == u.ustuck))
map_invisible(u.ux+u.dx, u.uy+u.dy);
return(TRUE);
}
STATIC_OVL boolean
known_hitum(mon, mhit, uattk) /* returns TRUE if monster still lives */
register struct monst *mon;
register int *mhit;
struct attack *uattk;
{
register boolean malive = TRUE;
if (override_confirmation) {
/* this may need to be generalized if weapons other than
Stormbringer acquire similar anti-social behavior... */
if (flags.verbose) Your("bloodthirsty blade attacks!");
}
if(!*mhit) {
missum(mon, uattk);
} else {
int oldhp = mon->mhp,
x = u.ux + u.dx, y = u.uy + u.dy;
/* KMH, conduct */
if (uwep && (uwep->oclass == WEAPON_CLASS || is_weptool(uwep)))
u.uconduct.weaphit++;
/* we hit the monster; be careful: it might die or
be knocked into a different location */
notonhead = (mon->mx != x || mon->my != y);
malive = hmon(mon, uwep, 0);
/* this assumes that Stormbringer was uwep not uswapwep */
if (malive && u.twoweap && !override_confirmation &&
m_at(x, y) == mon)
malive = hmon(mon, uswapwep, 0);
if (malive) {
/* monster still alive */
if(!rn2(25) && mon->mhp < mon->mhpmax/2
&& !(u.uswallow && mon == u.ustuck)) {
/* maybe should regurgitate if swallowed? */
if(!rn2(3)) {
monflee(mon, rnd(100), FALSE, TRUE);
} else monflee(mon, 0, FALSE, TRUE);
if(u.ustuck == mon && !u.uswallow && !sticks(youmonst.data))
u.ustuck = 0;
}
/* Vorpal Blade hit converted to miss */
/* could be headless monster or worm tail */
if (mon->mhp == oldhp) {
*mhit = 0;
/* a miss does not break conduct */
if (uwep &&
(uwep->oclass == WEAPON_CLASS || is_weptool(uwep)))
--u.uconduct.weaphit;
}
if (mon->wormno && *mhit)
cutworm(mon, x, y, uwep);
}
}
return(malive);
}
STATIC_OVL boolean
hitum(mon, tmp, uattk) /* returns TRUE if monster still lives */
struct monst *mon;
int tmp;
struct attack *uattk;
{
boolean malive;
int mhit = (tmp > (dieroll = rnd(20)) || u.uswallow);
if(tmp > dieroll) exercise(A_DEX, TRUE);
malive = known_hitum(mon, &mhit, uattk);
(void) passive(mon, mhit, malive, AT_WEAP);
return(malive);
}
boolean /* general "damage monster" routine */
hmon(mon, obj, thrown) /* return TRUE if mon still alive */
struct monst *mon;
struct obj *obj;
int thrown;
{
boolean result, anger_guards;
anger_guards = (mon->mpeaceful &&
(mon->ispriest || mon->isshk ||
mon->data == &mons[PM_WATCHMAN] ||
mon->data == &mons[PM_WATCH_CAPTAIN]));
result = hmon_hitmon(mon, obj, thrown);
if (mon->ispriest && !rn2(2)) ghod_hitsu(mon);
if (anger_guards) (void)angry_guards(!flags.soundok);
return result;
}
/* guts of hmon() */
STATIC_OVL boolean
hmon_hitmon(mon, obj, thrown)
struct monst *mon;
struct obj *obj;
int thrown;
{
int tmp;
struct permonst *mdat = mon->data;
int barehand_silver_rings = 0;
/* The basic reason we need all these booleans is that we don't want
* a "hit" message when a monster dies, so we have to know how much
* damage it did _before_ outputting a hit message, but any messages
* associated with the damage don't come out until _after_ outputting
* a hit message.
*/
boolean hittxt = FALSE, destroyed = FALSE, already_killed = FALSE;
boolean get_dmg_bonus = TRUE;
boolean ispoisoned = FALSE, needpoismsg = FALSE, poiskilled = FALSE;
boolean silvermsg = FALSE, silverobj = FALSE;
boolean valid_weapon_attack = FALSE;
boolean unarmed = !uwep && !uarm && !uarms;
#ifdef STEED
int jousting = 0;
#endif
int wtype;
struct obj *monwep;
char yourbuf[BUFSZ];
char unconventional[BUFSZ]; /* substituted for word "attack" in msg */
char saved_oname[BUFSZ];
unconventional[0] = '\0';
saved_oname[0] = '\0';
wakeup(mon);
if(!obj) { /* attack with bare hands */
if (mdat == &mons[PM_SHADE])
tmp = 0;
else if (martial_bonus())
tmp = rnd(4); /* bonus for martial arts */
else
tmp = rnd(2);
valid_weapon_attack = (tmp > 1);
/* blessed gloves give bonuses when fighting 'bare-handed' */
if (uarmg && uarmg->blessed && (is_undead(mdat) || is_demon(mdat)))
tmp += rnd(4);
/* So do silver rings. Note: rings are worn under gloves, so you
* don't get both bonuses.
*/
if (!uarmg) {
if (uleft && objects[uleft->otyp].oc_material == SILVER)
barehand_silver_rings++;
if (uright && objects[uright->otyp].oc_material == SILVER)
barehand_silver_rings++;
if (barehand_silver_rings && hates_silver(mdat)) {
tmp += rnd(20);
silvermsg = TRUE;
}
}
} else {
Strcpy(saved_oname, cxname(obj));
if(obj->oclass == WEAPON_CLASS || is_weptool(obj) ||
obj->oclass == GEM_CLASS) {
/* is it not a melee weapon? */
if (/* if you strike with a bow... */
is_launcher(obj) ||
/* or strike with a missile in your hand... */
(!thrown && (is_missile(obj) || is_ammo(obj))) ||
/* or use a pole at short range and not mounted... */
(!thrown &&
#ifdef STEED
!u.usteed &&
#endif
is_pole(obj)) ||
/* or throw a missile without the proper bow... */
(is_ammo(obj) && !ammo_and_launcher(obj, uwep))) {
/* then do only 1-2 points of damage */
if (mdat == &mons[PM_SHADE] && obj->otyp != SILVER_ARROW)
tmp = 0;
else
tmp = rnd(2);
if (!thrown && obj == uwep && obj->otyp == BOOMERANG &&
rnl(4) == 4-1) {
boolean more_than_1 = (obj->quan > 1L);
pline("As you hit %s, %s%s %s breaks into splinters.",
mon_nam(mon), more_than_1 ? "one of " : "",
shk_your(yourbuf, obj), xname(obj));
if (!more_than_1) uwepgone(); /* set unweapon */
useup(obj);
if (!more_than_1) obj = (struct obj *) 0;
hittxt = TRUE;
if (mdat != &mons[PM_SHADE])
tmp++;
}
} else {
tmp = dmgval(obj, mon);
/* a minimal hit doesn't exercise proficiency */
valid_weapon_attack = (tmp > 1);
if (!valid_weapon_attack || mon == u.ustuck || u.twoweap) {
; /* no special bonuses */
} else if (mon->mflee && Role_if(PM_ROGUE) && !Upolyd) {
You("strike %s from behind!", mon_nam(mon));
tmp += rnd(u.ulevel);
hittxt = TRUE;
} else if (dieroll == 2 && obj == uwep &&
obj->oclass == WEAPON_CLASS &&
(bimanual(obj) ||
(Role_if(PM_SAMURAI) && obj->otyp == KATANA && !uarms)) &&
((wtype = uwep_skill_type()) != P_NONE &&
P_SKILL(wtype) >= P_SKILLED) &&
((monwep = MON_WEP(mon)) != 0 &&
!is_flimsy(monwep) &&
!obj_resists(monwep,
50 + 15 * greatest_erosion(obj), 100))) {
/*
* 2.5% chance of shattering defender's weapon when
* using a two-handed weapon; less if uwep is rusted.
* [dieroll == 2 is most successful non-beheading or
* -bisecting hit, in case of special artifact damage;
* the percentage chance is (1/20)*(50/100).]
*/
setmnotwielded(mon,monwep);
MON_NOWEP(mon);
mon->weapon_check = NEED_WEAPON;
pline("%s %s %s from the force of your blow!",
s_suffix(Monnam(mon)), xname(monwep),
otense(monwep, "shatter"));
m_useup(mon, monwep);
/* If someone just shattered MY weapon, I'd flee! */
if (rn2(4)) {
monflee(mon, d(2,3), TRUE, TRUE);
}
hittxt = TRUE;
}
if (obj->oartifact &&
artifact_hit(&youmonst, mon, obj, &tmp, dieroll)) {
if(mon->mhp <= 0) /* artifact killed monster */
return FALSE;
if (tmp == 0) return TRUE;
hittxt = TRUE;
}
if (objects[obj->otyp].oc_material == SILVER
&& hates_silver(mdat)) {
silvermsg = TRUE; silverobj = TRUE;
}
#ifdef STEED
if (u.usteed && !thrown && tmp > 0 &&
weapon_type(obj) == P_LANCE && mon != u.ustuck) {
jousting = joust(mon, obj);
/* exercise skill even for minimal damage hits */
if (jousting) valid_weapon_attack = TRUE;
}
#endif
if (thrown && (is_ammo(obj) || is_missile(obj))) {
if (ammo_and_launcher(obj, uwep)) {
/* Elves and Samurai do extra damage using
* their bows&arrows; they're highly trained.
*/
if (Role_if(PM_SAMURAI) &&
obj->otyp == YA && uwep->otyp == YUMI)
tmp++;
else if (Race_if(PM_ELF) &&
obj->otyp == ELVEN_ARROW &&
uwep->otyp == ELVEN_BOW)
tmp++;
}
if(obj->opoisoned && is_poisonable(obj))
ispoisoned = TRUE;
}
}
} else if(obj->oclass == POTION_CLASS) {
if (obj->quan > 1L)
obj = splitobj(obj, 1L);
else
setuwep((struct obj *)0);
freeinv(obj);
potionhit(mon, obj, TRUE);
if (mon->mhp <= 0) return FALSE; /* killed */
hittxt = TRUE;
/* in case potion effect causes transformation */
mdat = mon->data;
tmp = (mdat == &mons[PM_SHADE]) ? 0 : 1;
} else {
if (mdat == &mons[PM_SHADE] && !shade_aware(obj)) {
tmp = 0;
Strcpy(unconventional, cxname(obj));
} else {
switch(obj->otyp) {
case BOULDER: /* 1d20 */
case HEAVY_IRON_BALL: /* 1d25 */
case IRON_CHAIN: /* 1d4+1 */
tmp = dmgval(obj, mon);
break;
case MIRROR:
if (breaktest(obj)) {
You("break %s mirror. That's bad luck!",
shk_your(yourbuf, obj));
change_luck(-2);
useup(obj);
obj = (struct obj *) 0;
unarmed = FALSE; /* avoid obj==0 confusion */
get_dmg_bonus = FALSE;
hittxt = TRUE;
}
tmp = 1;
break;
#ifdef TOURIST
case EXPENSIVE_CAMERA:
You("succeed in destroying %s camera. Congratulations!",
shk_your(yourbuf, obj));
useup(obj);
return(TRUE);
/*NOTREACHED*/
break;
#endif
case CORPSE: /* fixed by polder@cs.vu.nl */
if (touch_petrifies(&mons[obj->corpsenm])) {
static const char withwhat[] = "corpse";
tmp = 1;
hittxt = TRUE;
You("hit %s with %s %s.", mon_nam(mon),
obj->dknown ? the(mons[obj->corpsenm].mname) :
an(mons[obj->corpsenm].mname),
(obj->quan > 1) ? makeplural(withwhat) : withwhat);
if (!munstone(mon, TRUE))
minstapetrify(mon, TRUE);
if (resists_ston(mon)) break;
/* note: hp may be <= 0 even if munstoned==TRUE */
return (boolean) (mon->mhp > 0);
#if 0
} else if (touch_petrifies(mdat)) {
/* maybe turn the corpse into a statue? */
#endif
}
tmp = (obj->corpsenm >= LOW_PM ?
mons[obj->corpsenm].msize : 0) + 1;
break;
case EGG:
{
#define useup_eggs(o) { if (thrown) obfree(o,(struct obj *)0); \
else useupall(o); \
o = (struct obj *)0; } /* now gone */
long cnt = obj->quan;
tmp = 1; /* nominal physical damage */
get_dmg_bonus = FALSE;
hittxt = TRUE; /* message always given */
/* egg is always either used up or transformed, so next
hand-to-hand attack should yield a "bashing" mesg */
if (obj == uwep) unweapon = TRUE;
if (obj->spe && obj->corpsenm >= LOW_PM) {
if (obj->quan < 5)
change_luck((schar) -(obj->quan));
else
change_luck(-5);
}
if (touch_petrifies(&mons[obj->corpsenm])) {
/*learn_egg_type(obj->corpsenm);*/
pline("Splat! You hit %s with %s %s egg%s!",
mon_nam(mon),
obj->known ? "the" : cnt > 1L ? "some" : "a",
obj->known ? mons[obj->corpsenm].mname : "petrifying",
plur(cnt));
obj->known = 1; /* (not much point...) */
useup_eggs(obj);
if (!munstone(mon, TRUE))
minstapetrify(mon, TRUE);
if (resists_ston(mon)) break;
return (boolean) (mon->mhp > 0);
} else { /* ordinary egg(s) */
const char *eggp =
(obj->corpsenm != NON_PM && obj->known) ?
the(mons[obj->corpsenm].mname) :
(cnt > 1L) ? "some" : "an";
You("hit %s with %s egg%s.",
mon_nam(mon), eggp, plur(cnt));
if (touch_petrifies(mdat) && !stale_egg(obj)) {
pline_The("egg%s %s alive any more...",
plur(cnt),
(cnt == 1L) ? "isn't" : "aren't");
if (obj->timed) obj_stop_timers(obj);
obj->otyp = ROCK;
obj->oclass = GEM_CLASS;
obj->oartifact = 0;
obj->spe = 0;
obj->known = obj->dknown = obj->bknown = 0;
obj->owt = weight(obj);
if (thrown) place_object(obj, mon->mx, mon->my);
} else {
pline("Splat!");
useup_eggs(obj);
exercise(A_WIS, FALSE);
}
}
break;
#undef useup_eggs
}
case CLOVE_OF_GARLIC: /* no effect against demons */
if (is_undead(mdat)) {
monflee(mon, d(2, 4), FALSE, TRUE);
}
tmp = 1;
break;
case CREAM_PIE:
case BLINDING_VENOM:
mon->msleeping = 0;
if (can_blnd(&youmonst, mon, (uchar)
(obj->otyp == BLINDING_VENOM
? AT_SPIT : AT_WEAP), obj)) {
if (Blind) {
pline(obj->otyp == CREAM_PIE ?
"Splat!" : "Splash!");
} else if (obj->otyp == BLINDING_VENOM) {
pline_The("venom blinds %s%s!", mon_nam(mon),
mon->mcansee ? "" : " further");
} else {
char *whom = mon_nam(mon);
char *what = The(xname(obj));
if (!thrown && obj->quan > 1)
what = An(singular(obj, xname));
/* note: s_suffix returns a modifiable buffer */
if (haseyes(mdat)
&& mdat != &mons[PM_FLOATING_EYE])
whom = strcat(strcat(s_suffix(whom), " "),
mbodypart(mon, FACE));
pline("%s %s over %s!",
what, vtense(what, "splash"), whom);
}
setmangry(mon);
mon->mcansee = 0;
tmp = rn1(25, 21);
if(((int) mon->mblinded + tmp) > 127)
mon->mblinded = 127;
else mon->mblinded += tmp;
} else {
pline(obj->otyp==CREAM_PIE ? "Splat!" : "Splash!");
setmangry(mon);
}
if (thrown) obfree(obj, (struct obj *)0);
else useup(obj);
hittxt = TRUE;
get_dmg_bonus = FALSE;
tmp = 0;
break;
case ACID_VENOM: /* thrown (or spit) */
if (resists_acid(mon)) {
Your("venom hits %s harmlessly.",
mon_nam(mon));
tmp = 0;
} else {
Your("venom burns %s!", mon_nam(mon));
tmp = dmgval(obj, mon);
}
if (thrown) obfree(obj, (struct obj *)0);
else useup(obj);
hittxt = TRUE;
get_dmg_bonus = FALSE;
break;
default:
/* non-weapons can damage because of their weight */
/* (but not too much) */
tmp = obj->owt/100;
if(tmp < 1) tmp = 1;
else tmp = rnd(tmp);
if(tmp > 6) tmp = 6;
/*
* Things like silver wands can arrive here so
* so we need another silver check.
*/
if (objects[obj->otyp].oc_material == SILVER
&& hates_silver(mdat)) {
tmp += rnd(20);
silvermsg = TRUE; silverobj = TRUE;
}
}
}
}
}
/****** NOTE: perhaps obj is undefined!! (if !thrown && BOOMERANG)
* *OR* if attacking bare-handed!! */
if (get_dmg_bonus && tmp > 0) {
tmp += u.udaminc;
/* If you throw using a propellor, you don't get a strength
* bonus but you do get an increase-damage bonus.
*/
if(!thrown || !obj || !uwep || !ammo_and_launcher(obj, uwep))
tmp += dbon();
}
if (valid_weapon_attack) {
struct obj *wep;
/* to be valid a projectile must have had the correct projector */
wep = PROJECTILE(obj) ? uwep : obj;
tmp += weapon_dam_bonus(wep);
/* [this assumes that `!thrown' implies wielded...] */
wtype = thrown ? weapon_type(wep) : uwep_skill_type();
use_skill(wtype, 1);
}
if (ispoisoned) {
int nopoison = (10 - (obj->owt/10));
if(nopoison < 2) nopoison = 2;
if Role_if(PM_SAMURAI) {
You("dishonorably use a poisoned weapon!");
adjalign(-sgn(u.ualign.type));
} else if ((u.ualign.type == A_LAWFUL) && (u.ualign.record > -10)) {
You_feel("like an evil coward for using a poisoned weapon.");
adjalign(-1);
}
if (obj && !rn2(nopoison)) {
obj->opoisoned = FALSE;
Your("%s %s no longer poisoned.", xname(obj),
otense(obj, "are"));
}
if (resists_poison(mon))
needpoismsg = TRUE;
else if (rn2(10))
tmp += rnd(6);
else poiskilled = TRUE;
}
if (tmp < 1) {
/* make sure that negative damage adjustment can't result
in inadvertently boosting the victim's hit points */
tmp = 0;
if (mdat == &mons[PM_SHADE]) {
if (!hittxt) {
const char *what = unconventional[0] ? unconventional : "attack";
Your("%s %s harmlessly through %s.",
what, vtense(what, "pass"),
mon_nam(mon));
hittxt = TRUE;
}
} else {
if (get_dmg_bonus) tmp = 1;
}
}
#ifdef STEED
if (jousting) {
tmp += d(2, (obj == uwep) ? 10 : 2); /* [was in dmgval()] */
You("joust %s%s",
mon_nam(mon), canseemon(mon) ? exclam(tmp) : ".");
if (jousting < 0) {
Your("%s shatters on impact!", xname(obj));
/* (must be either primary or secondary weapon to get here) */
u.twoweap = FALSE; /* untwoweapon() is too verbose here */
if (obj == uwep) uwepgone(); /* set unweapon */
/* minor side-effect: broken lance won't split puddings */
useup(obj);
obj = 0;
}
/* avoid migrating a dead monster */
if (mon->mhp > tmp) {
mhurtle(mon, u.dx, u.dy, 1);
mdat = mon->data; /* in case of a polymorph trap */
if (DEADMONSTER(mon)) already_killed = TRUE;
}
hittxt = TRUE;
} else
#endif
/* VERY small chance of stunning opponent if unarmed. */
if (unarmed && tmp > 1 && !thrown && !obj && !Upolyd) {
if (rnd(100) < P_SKILL(P_BARE_HANDED_COMBAT) &&
!bigmonst(mdat) && !thick_skinned(mdat)) {
if (canspotmon(mon))
pline("%s %s from your powerful strike!", Monnam(mon),
makeplural(stagger(mon->data, "stagger")));
/* avoid migrating a dead monster */
if (mon->mhp > tmp) {
mhurtle(mon, u.dx, u.dy, 1);
mdat = mon->data; /* in case of a polymorph trap */
if (DEADMONSTER(mon)) already_killed = TRUE;
}
hittxt = TRUE;
}
}
if (!already_killed) mon->mhp -= tmp;
/* adjustments might have made tmp become less than what
a level draining artifact has already done to max HP */
if (mon->mhp > mon->mhpmax) mon->mhp = mon->mhpmax;
if (mon->mhp < 1)
destroyed = TRUE;
if (mon->mtame && (!mon->mflee || mon->mfleetim) && tmp > 0) {
abuse_dog(mon);
monflee(mon, 10 * rnd(tmp), FALSE, FALSE);
}
if((mdat == &mons[PM_BLACK_PUDDING] || mdat == &mons[PM_BROWN_PUDDING])
&& obj && obj == uwep
&& objects[obj->otyp].oc_material == IRON
&& mon->mhp > 1 && !thrown && !mon->mcan
/* && !destroyed -- guaranteed by mhp > 1 */ ) {
if (clone_mon(mon, 0, 0)) {
pline("%s divides as you hit it!", Monnam(mon));
hittxt = TRUE;
}
}
if (!hittxt && /*( thrown => obj exists )*/
(!destroyed || (thrown && m_shot.n > 1 && m_shot.o == obj->otyp))) {
if (thrown) hit(mshot_xname(obj), mon, exclam(tmp));
else if (!flags.verbose) You("hit it.");
else You("%s %s%s", Role_if(PM_BARBARIAN) ? "smite" : "hit",
mon_nam(mon), canseemon(mon) ? exclam(tmp) : ".");
}
if (silvermsg) {
const char *fmt;
char *whom = mon_nam(mon);
char silverobjbuf[BUFSZ];
if (canspotmon(mon)) {
if (barehand_silver_rings == 1)
fmt = "Your silver ring sears %s!";
else if (barehand_silver_rings == 2)
fmt = "Your silver rings sear %s!";
else if (silverobj && saved_oname[0]) {
Sprintf(silverobjbuf, "Your %s%s %s %%s!",
strstri(saved_oname, "silver") ?
"" : "silver ",
saved_oname, vtense(saved_oname, "sear"));
fmt = silverobjbuf;
} else
fmt = "The silver sears %s!";
} else {
*whom = highc(*whom); /* "it" -> "It" */
fmt = "%s is seared!";
}
/* note: s_suffix returns a modifiable buffer */
if (!noncorporeal(mdat))
whom = strcat(s_suffix(whom), " flesh");
pline(fmt, whom);
}
if (needpoismsg)
pline_The("poison doesn't seem to affect %s.", mon_nam(mon));
if (poiskilled) {
pline_The("poison was deadly...");
if (!already_killed) xkilled(mon, 0);
return FALSE;
} else if (destroyed) {
if (!already_killed)
killed(mon); /* takes care of most messages */
} else if(u.umconf && !thrown) {
nohandglow(mon);
if (!mon->mconf && !resist(mon, SPBOOK_CLASS, 0, NOTELL)) {
mon->mconf = 1;
if (!mon->mstun && mon->mcanmove && !mon->msleeping &&
canseemon(mon))
pline("%s appears confused.", Monnam(mon));
}
}
return((boolean)(destroyed ? FALSE : TRUE));
}
STATIC_OVL boolean
shade_aware(obj)
struct obj *obj;
{
if (!obj) return FALSE;
/*
* The things in this list either
* 1) affect shades.
* OR
* 2) are dealt with properly by other routines
* when it comes to shades.
*/
if (obj->otyp == BOULDER || obj->otyp == HEAVY_IRON_BALL
|| obj->otyp == IRON_CHAIN /* dmgval handles those first three */
|| obj->otyp == MIRROR /* silver in the reflective surface */
|| obj->otyp == CLOVE_OF_GARLIC /* causes shades to flee */
|| objects[obj->otyp].oc_material == SILVER)
return TRUE;
return FALSE;
}
/* check whether slippery clothing protects from hug or wrap attack */
/* [currently assumes that you are the attacker] */
STATIC_OVL boolean
m_slips_free(mdef, mattk)
struct monst *mdef;
struct attack *mattk;
{
struct obj *obj;
if (mattk->adtyp == AD_DRIN) {
/* intelligence drain attacks the head */
obj = which_armor(mdef, W_ARMH);
} else {
/* grabbing attacks the body */
obj = which_armor(mdef, W_ARMC); /* cloak */
if (!obj) obj = which_armor(mdef, W_ARM); /* suit */
#ifdef TOURIST
if (!obj) obj = which_armor(mdef, W_ARMU); /* shirt */
#endif
}
/* if your cloak/armor is greased, monster slips off; this
protection might fail (33% chance) when the armor is cursed */
if (obj && (obj->greased || obj->otyp == OILSKIN_CLOAK) &&
(!obj->cursed || rn2(3))) {
You("%s %s %s %s!",
mattk->adtyp == AD_WRAP ?
"slip off of" : "grab, but cannot hold onto",
s_suffix(mon_nam(mdef)),
obj->greased ? "greased" : "slippery",
/* avoid "slippery slippery cloak"
for undiscovered oilskin cloak */
(obj->greased || objects[obj->otyp].oc_name_known) ?
xname(obj) : cloak_simple_name(obj));
if (obj->greased && !rn2(2)) {
pline_The("grease wears off.");
obj->greased = 0;
}
return TRUE;
}
return FALSE;
}
/* used when hitting a monster with a lance while mounted */
STATIC_OVL int /* 1: joust hit; 0: ordinary hit; -1: joust but break lance */
joust(mon, obj)
struct monst *mon; /* target */
struct obj *obj; /* weapon */
{
int skill_rating, joust_dieroll;
if (Fumbling || Stunned) return 0;
/* sanity check; lance must be wielded in order to joust */
if (obj != uwep && (obj != uswapwep || !u.twoweap)) return 0;
/* if using two weapons, use worse of lance and two-weapon skills */
skill_rating = P_SKILL(weapon_type(obj)); /* lance skill */
if (u.twoweap && P_SKILL(P_TWO_WEAPON_COMBAT) < skill_rating)
skill_rating = P_SKILL(P_TWO_WEAPON_COMBAT);
if (skill_rating == P_ISRESTRICTED) skill_rating = P_UNSKILLED; /* 0=>1 */
/* odds to joust are expert:80%, skilled:60%, basic:40%, unskilled:20% */
if ((joust_dieroll = rn2(5)) < skill_rating) {
if (joust_dieroll == 0 && rnl(50) == (50-1) &&
!unsolid(mon->data) && !obj_resists(obj, 0, 100))
return -1; /* hit that breaks lance */
return 1; /* successful joust */
}
return 0; /* no joust bonus; revert to ordinary attack */
}
/*
* Send in a demon pet for the hero. Exercise wisdom.
*
* This function used to be inline to damageum(), but the Metrowerks compiler
* (DR4 and DR4.5) screws up with an internal error 5 "Expression Too Complex."
* Pulling it out makes it work.
*/
STATIC_OVL void
demonpet()
{
int i;
struct permonst *pm;
struct monst *dtmp;
pline("Some hell-p has arrived!");
i = !rn2(6) ? ndemon(u.ualign.type) : NON_PM;
pm = i != NON_PM ? &mons[i] : youmonst.data;
if ((dtmp = makemon(pm, u.ux, u.uy, NO_MM_FLAGS)) != 0)
(void)tamedog(dtmp, (struct obj *)0);
exercise(A_WIS, TRUE);
}
/*
* Player uses theft attack against monster.
*
* If the target is wearing body armor, take all of its possesions;
* otherwise, take one object. [Is this really the behavior we want?]
*
* This routine implicitly assumes that there is no way to be able to
* resist petfication (ie, be polymorphed into a xorn or golem) at the
* same time as being able to steal (poly'd into nymph or succubus).
* If that ever changes, the check for touching a cockatrice corpse
* will need to be smarter about whether to break out of the theft loop.
*/
STATIC_OVL void
steal_it(mdef, mattk)
struct monst *mdef;
struct attack *mattk;
{
struct obj *otmp, *stealoid, **minvent_ptr;
long unwornmask;
if (!mdef->minvent) return; /* nothing to take */
/* look for worn body armor */
stealoid = (struct obj *)0;
if (could_seduce(&youmonst, mdef, mattk)) {
/* find armor, and move it to end of inventory in the process */
minvent_ptr = &mdef->minvent;
while ((otmp = *minvent_ptr) != 0)
if (otmp->owornmask & W_ARM) {
if (stealoid) panic("steal_it: multiple worn suits");
*minvent_ptr = otmp->nobj; /* take armor out of minvent */
stealoid = otmp;
stealoid->nobj = (struct obj *)0;
} else {
minvent_ptr = &otmp->nobj;
}
*minvent_ptr = stealoid; /* put armor back into minvent */
}
if (stealoid) { /* we will be taking everything */
if (gender(mdef) == (int) u.mfemale &&
youmonst.data->mlet == S_NYMPH)
You("charm %s. She gladly hands over her possessions.",
mon_nam(mdef));
else
You("seduce %s and %s starts to take off %s clothes.",
mon_nam(mdef), mhe(mdef), mhis(mdef));
}
while ((otmp = mdef->minvent) != 0) {
if (!Upolyd) break; /* no longer have ability to steal */
/* take the object away from the monster */
obj_extract_self(otmp);
if ((unwornmask = otmp->owornmask) != 0L) {
mdef->misc_worn_check &= ~unwornmask;
if (otmp->owornmask & W_WEP) {
setmnotwielded(mdef,otmp);
MON_NOWEP(mdef);
}
otmp->owornmask = 0L;
update_mon_intrinsics(mdef, otmp, FALSE, FALSE);
if (otmp == stealoid) /* special message for final item */
pline("%s finishes taking off %s suit.",
Monnam(mdef), mhis(mdef));
}
/* give the object to the character */
otmp = hold_another_object(otmp, "You snatched but dropped %s.",
doname(otmp), "You steal: ");
if (otmp->where != OBJ_INVENT) continue;
if (otmp->otyp == CORPSE &&
touch_petrifies(&mons[otmp->corpsenm]) && !uarmg) {
char kbuf[BUFSZ];
Sprintf(kbuf, "stolen %s corpse", mons[otmp->corpsenm].mname);
instapetrify(kbuf);
break; /* stop the theft even if hero survives */
}
/* more take-away handling, after theft message */
if (unwornmask & W_WEP) { /* stole wielded weapon */
possibly_unwield(mdef, FALSE);
} else if (unwornmask & W_ARMG) { /* stole worn gloves */
mselftouch(mdef, (const char *)0, TRUE);
if (mdef->mhp <= 0) /* it's now a statue */
return; /* can't continue stealing */
}
if (!stealoid) break; /* only taking one item */
}
}
int
damageum(mdef, mattk)
register struct monst *mdef;
register struct attack *mattk;
{
register struct permonst *pd = mdef->data;
register int tmp = d((int)mattk->damn, (int)mattk->damd);
int armpro;
boolean negated;
armpro = magic_negation(mdef);
/* since hero can't be cancelled, only defender's armor applies */
negated = !((rn2(3) >= armpro) || !rn2(50));
if (is_demon(youmonst.data) && !rn2(13) && !uwep
&& u.umonnum != PM_SUCCUBUS && u.umonnum != PM_INCUBUS
&& u.umonnum != PM_BALROG) {
demonpet();
return(0);
}
switch(mattk->adtyp) {
case AD_STUN:
if(!Blind)
pline("%s %s for a moment.", Monnam(mdef),
makeplural(stagger(mdef->data, "stagger")));
mdef->mstun = 1;
goto physical;
case AD_LEGS:
/* if (u.ucancelled) { */
/* tmp = 0; */
/* break; */
/* } */
goto physical;
case AD_WERE: /* no special effect on monsters */
case AD_HEAL: /* likewise */
case AD_PHYS:
physical:
if(mattk->aatyp == AT_WEAP) {
if(uwep) tmp = 0;
} else if(mattk->aatyp == AT_KICK) {
if(thick_skinned(mdef->data)) tmp = 0;
if(mdef->data == &mons[PM_SHADE]) {
if (!(uarmf && uarmf->blessed)) {
impossible("bad shade attack function flow?");
tmp = 0;
} else
tmp = rnd(4); /* bless damage */
}
}
break;
case AD_FIRE:
if (negated) {
tmp = 0;
break;
}
if (!Blind)
pline("%s is %s!", Monnam(mdef),
on_fire(mdef->data, mattk));
if (pd == &mons[PM_STRAW_GOLEM] ||
pd == &mons[PM_PAPER_GOLEM]) {
if (!Blind)
pline("%s burns completely!", Monnam(mdef));
xkilled(mdef,2);
tmp = 0;
break;
/* Don't return yet; keep hp<1 and tmp=0 for pet msg */
}
tmp += destroy_mitem(mdef, SCROLL_CLASS, AD_FIRE);
tmp += destroy_mitem(mdef, SPBOOK_CLASS, AD_FIRE);
if (resists_fire(mdef)) {
if (!Blind)
pline_The("fire doesn't heat %s!", mon_nam(mdef));
golemeffects(mdef, AD_FIRE, tmp);
shieldeff(mdef->mx, mdef->my);
tmp = 0;
}
/* only potions damage resistant players in destroy_item */
tmp += destroy_mitem(mdef, POTION_CLASS, AD_FIRE);
break;
case AD_COLD:
if (negated) {
tmp = 0;
break;
}
if (!Blind) pline("%s is covered in frost!", Monnam(mdef));
if (resists_cold(mdef)) {
shieldeff(mdef->mx, mdef->my);
if (!Blind)
pline_The("frost doesn't chill %s!", mon_nam(mdef));
golemeffects(mdef, AD_COLD, tmp);
tmp = 0;
}
tmp += destroy_mitem(mdef, POTION_CLASS, AD_COLD);
break;
case AD_ELEC:
if (negated) {
tmp = 0;
break;
}
if (!Blind) pline("%s is zapped!", Monnam(mdef));
tmp += destroy_mitem(mdef, WAND_CLASS, AD_ELEC);
if (resists_elec(mdef)) {
if (!Blind)
pline_The("zap doesn't shock %s!", mon_nam(mdef));
golemeffects(mdef, AD_ELEC, tmp);
shieldeff(mdef->mx, mdef->my);
tmp = 0;
}
/* only rings damage resistant players in destroy_item */
tmp += destroy_mitem(mdef, RING_CLASS, AD_ELEC);
break;
case AD_ACID:
if (resists_acid(mdef)) tmp = 0;
break;
case AD_STON:
if (!munstone(mdef, TRUE))
minstapetrify(mdef, TRUE);
tmp = 0;
break;
#ifdef SEDUCE
case AD_SSEX:
#endif
case AD_SEDU:
case AD_SITM:
steal_it(mdef, mattk);
tmp = 0;
break;
case AD_SGLD:
#ifndef GOLDOBJ
if (mdef->mgold) {
u.ugold += mdef->mgold;
mdef->mgold = 0;
Your("purse feels heavier.");
}
#else
/* This you as a leprechaun, so steal
real gold only, no lesser coins */
{
struct obj *mongold = findgold(mdef->minvent);
if (mongold) {
obj_extract_self(mongold);
if (merge_choice(invent, mongold) || inv_cnt() < 52) {
addinv(mongold);
Your("purse feels heavier.");
} else {
You("grab %s's gold, but find no room in your knapsack.", mon_nam(mdef));
dropy(mongold);
}
}
}
#endif
exercise(A_DEX, TRUE);
tmp = 0;
break;
case AD_TLPT:
if (tmp <= 0) tmp = 1;
if (!negated && tmp < mdef->mhp) {
char nambuf[BUFSZ];
boolean u_saw_mon = canseemon(mdef) ||
(u.uswallow && u.ustuck == mdef);
/* record the name before losing sight of monster */
Strcpy(nambuf, Monnam(mdef));
if (u_teleport_mon(mdef, FALSE) &&
u_saw_mon && !canseemon(mdef))
pline("%s suddenly disappears!", nambuf);
}
break;
case AD_BLND:
if (can_blnd(&youmonst, mdef, mattk->aatyp, (struct obj*)0)) {
if(!Blind && mdef->mcansee)
pline("%s is blinded.", Monnam(mdef));
mdef->mcansee = 0;
tmp += mdef->mblinded;
if (tmp > 127) tmp = 127;
mdef->mblinded = tmp;
}
tmp = 0;
break;
case AD_CURS:
if (night() && !rn2(10) && !mdef->mcan) {
if (mdef->data == &mons[PM_CLAY_GOLEM]) {
if (!Blind)
pline("Some writing vanishes from %s head!",
s_suffix(mon_nam(mdef)));
xkilled(mdef, 0);
/* Don't return yet; keep hp<1 and tmp=0 for pet msg */
} else {
mdef->mcan = 1;
You("chuckle.");
}
}
tmp = 0;
break;
case AD_DRLI:
if (!negated && !rn2(3) && !resists_drli(mdef)) {
int xtmp = d(2,6);
pline("%s suddenly seems weaker!", Monnam(mdef));
mdef->mhpmax -= xtmp;
if ((mdef->mhp -= xtmp) <= 0 || !mdef->m_lev) {
pline("%s dies!", Monnam(mdef));
xkilled(mdef,0);
} else
mdef->m_lev--;
tmp = 0;
}
break;
case AD_RUST:
if (pd == &mons[PM_IRON_GOLEM]) {
pline("%s falls to pieces!", Monnam(mdef));
xkilled(mdef,0);
}
hurtmarmor(mdef, AD_RUST);
tmp = 0;
break;
case AD_CORR:
hurtmarmor(mdef, AD_CORR);
tmp = 0;
break;
case AD_DCAY:
if (pd == &mons[PM_WOOD_GOLEM] ||
pd == &mons[PM_LEATHER_GOLEM]) {
pline("%s falls to pieces!", Monnam(mdef));
xkilled(mdef,0);
}
hurtmarmor(mdef, AD_DCAY);
tmp = 0;
break;
case AD_DRST:
case AD_DRDX:
case AD_DRCO:
if (!negated && !rn2(8)) {
Your("%s was poisoned!", mpoisons_subj(&youmonst, mattk));
if (resists_poison(mdef))
pline_The("poison doesn't seem to affect %s.",
mon_nam(mdef));
else {
if (!rn2(10)) {
Your("poison was deadly...");
tmp = mdef->mhp;
} else tmp += rn1(10,6);
}
}
break;
case AD_DRIN:
if (notonhead || !has_head(mdef->data)) {
pline("%s doesn't seem harmed.", Monnam(mdef));
tmp = 0;
if (!Unchanging && mdef->data == &mons[PM_GREEN_SLIME]) {
if (!Slimed) {
You("suck in some slime and don't feel very well.");
Slimed = 10L;
}
}
break;
}
if (m_slips_free(mdef, mattk)) break;
if ((mdef->misc_worn_check & W_ARMH) && rn2(8)) {
pline("%s helmet blocks your attack to %s head.",
s_suffix(Monnam(mdef)), mhis(mdef));
break;
}
You("eat %s brain!", s_suffix(mon_nam(mdef)));
u.uconduct.food++;
if (touch_petrifies(mdef->data) && !Stone_resistance && !Stoned) {
Stoned = 5;
killer_format = KILLED_BY_AN;
delayed_killer = mdef->data->mname;
}
if (!vegan(mdef->data))
u.uconduct.unvegan++;
if (!vegetarian(mdef->data))
violated_vegetarian();
if (mindless(mdef->data)) {
pline("%s doesn't notice.", Monnam(mdef));
break;
}
tmp += rnd(10);
morehungry(-rnd(30)); /* cannot choke */
if (ABASE(A_INT) < AMAX(A_INT)) {
ABASE(A_INT) += rnd(4);
if (ABASE(A_INT) > AMAX(A_INT))
ABASE(A_INT) = AMAX(A_INT);
flags.botl = 1;
}
exercise(A_WIS, TRUE);
break;
case AD_STCK:
if (!negated && !sticks(mdef->data))
u.ustuck = mdef; /* it's now stuck to you */
break;
case AD_WRAP:
if (!sticks(mdef->data)) {
if (!u.ustuck && !rn2(10)) {
if (m_slips_free(mdef, mattk)) {
tmp = 0;
} else {
You("swing yourself around %s!",
mon_nam(mdef));
u.ustuck = mdef;
}
} else if(u.ustuck == mdef) {
/* Monsters don't wear amulets of magical breathing */
if (is_pool(u.ux,u.uy) && !is_swimmer(mdef->data) &&
!amphibious(mdef->data)) {
You("drown %s...", mon_nam(mdef));
tmp = mdef->mhp;
} else if(mattk->aatyp == AT_HUGS)
pline("%s is being crushed.", Monnam(mdef));
} else {
tmp = 0;
if (flags.verbose)
You("brush against %s %s.",
s_suffix(mon_nam(mdef)),
mbodypart(mdef, LEG));
}
} else tmp = 0;
break;
case AD_PLYS:
if (!negated && mdef->mcanmove && !rn2(3) && tmp < mdef->mhp) {
if (!Blind) pline("%s is frozen by you!", Monnam(mdef));
mdef->mcanmove = 0;
mdef->mfrozen = rnd(10);
}
break;
case AD_SLEE:
if (!negated && !mdef->msleeping &&
sleep_monst(mdef, rnd(10), -1)) {
if (!Blind)
pline("%s is put to sleep by you!", Monnam(mdef));
slept_monst(mdef);
}
break;
case AD_SLIM:
if (negated) break; /* physical damage only */
if (!rn2(4) && !flaming(mdef->data) &&
mdef->data != &mons[PM_GREEN_SLIME]) {
You("turn %s into slime.", mon_nam(mdef));
(void) newcham(mdef, &mons[PM_GREEN_SLIME], FALSE, FALSE);
tmp = 0;
}
break;
case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
/* there's no msomearmor() function, so just do damage */
/* if (negated) break; */
break;
case AD_SLOW:
if (!negated && mdef->mspeed != MSLOW) {
unsigned int oldspeed = mdef->mspeed;
mon_adjust_speed(mdef, -1, (struct obj *)0);
if (mdef->mspeed != oldspeed && canseemon(mdef))
pline("%s slows down.", Monnam(mdef));
}
break;
case AD_CONF:
if (!mdef->mconf) {
if (canseemon(mdef))
pline("%s looks confused.", Monnam(mdef));
mdef->mconf = 1;
}
break;
default: tmp = 0;
break;
}
mdef->mstrategy &= ~STRAT_WAITFORU; /* in case player is very fast */
if((mdef->mhp -= tmp) < 1) {
if (mdef->mtame && !cansee(mdef->mx,mdef->my)) {
You_feel("embarrassed for a moment.");
if (tmp) xkilled(mdef, 0); /* !tmp but hp<1: already killed */
} else if (!flags.verbose) {
You("destroy it!");
if (tmp) xkilled(mdef, 0);
} else
if (tmp) killed(mdef);
return(2);
}
return(1);
}
STATIC_OVL int
explum(mdef, mattk)
register struct monst *mdef;
register struct attack *mattk;
{
register int tmp = d((int)mattk->damn, (int)mattk->damd);
You("explode!");
switch(mattk->adtyp) {
boolean resistance; /* only for cold/fire/elec */
case AD_BLND:
if (!resists_blnd(mdef)) {
pline("%s is blinded by your flash of light!", Monnam(mdef));
mdef->mblinded = min((int)mdef->mblinded + tmp, 127);
mdef->mcansee = 0;
}
break;
case AD_HALU:
if (haseyes(mdef->data) && mdef->mcansee) {
pline("%s is affected by your flash of light!",
Monnam(mdef));
mdef->mconf = 1;
}
break;
case AD_COLD:
resistance = resists_cold(mdef);
goto common;
case AD_FIRE:
resistance = resists_fire(mdef);
goto common;
case AD_ELEC:
resistance = resists_elec(mdef);
common:
if (!resistance) {
pline("%s gets blasted!", Monnam(mdef));
mdef->mhp -= tmp;
if (mdef->mhp <= 0) {
killed(mdef);
return(2);
}
} else {
shieldeff(mdef->mx, mdef->my);
if (is_golem(mdef->data))
golemeffects(mdef, (int)mattk->adtyp, tmp);
else
pline_The("blast doesn't seem to affect %s.",
mon_nam(mdef));
}
break;
default:
break;
}
return(1);
}
STATIC_OVL void
start_engulf(mdef)
struct monst *mdef;
{
if (!Invisible) {
map_location(u.ux, u.uy, TRUE);
tmp_at(DISP_ALWAYS, mon_to_glyph(&youmonst));
tmp_at(mdef->mx, mdef->my);
}
You("engulf %s!", mon_nam(mdef));
delay_output();
delay_output();
}
STATIC_OVL void
end_engulf()
{
if (!Invisible) {
tmp_at(DISP_END, 0);
newsym(u.ux, u.uy);
}
}
STATIC_OVL int
gulpum(mdef,mattk)
register struct monst *mdef;
register struct attack *mattk;
{
register int tmp;
register int dam = d((int)mattk->damn, (int)mattk->damd);
struct obj *otmp;
/* Not totally the same as for real monsters. Specifically, these
* don't take multiple moves. (It's just too hard, for too little
* result, to program monsters which attack from inside you, which
* would be necessary if done accurately.) Instead, we arbitrarily
* kill the monster immediately for AD_DGST and we regurgitate them
* after exactly 1 round of attack otherwise. -KAA
*/
if(mdef->data->msize >= MZ_HUGE) return 0;
if(u.uhunger < 1500 && !u.uswallow) {
for (otmp = mdef->minvent; otmp; otmp = otmp->nobj)
(void) snuff_lit(otmp);
if(!touch_petrifies(mdef->data) || Stone_resistance) {
#ifdef LINT /* static char msgbuf[BUFSZ]; */
char msgbuf[BUFSZ];
#else
static char msgbuf[BUFSZ];
#endif
start_engulf(mdef);
switch(mattk->adtyp) {
case AD_DGST:
/* eating a Rider or its corpse is fatal */
if (is_rider(mdef->data)) {
pline("Unfortunately, digesting any of it is fatal.");
end_engulf();
Sprintf(msgbuf, "unwisely tried to eat %s",
mdef->data->mname);
killer = msgbuf;
killer_format = NO_KILLER_PREFIX;
done(DIED);
return 0; /* lifesaved */
}
if (Slow_digestion) {
dam = 0;
break;
}
/* KMH, conduct */
u.uconduct.food++;
if (!vegan(mdef->data))
u.uconduct.unvegan++;
if (!vegetarian(mdef->data))
violated_vegetarian();
/* Use up amulet of life saving */
if (!!(otmp = mlifesaver(mdef))) m_useup(mdef, otmp);
newuhs(FALSE);
xkilled(mdef,2);
if (mdef->mhp > 0) { /* monster lifesaved */
You("hurriedly regurgitate the sizzling in your %s.",
body_part(STOMACH));
} else {
tmp = 1 + (mdef->data->cwt >> 8);
if (corpse_chance(mdef, &youmonst, TRUE) &&
!(mvitals[monsndx(mdef->data)].mvflags &
G_NOCORPSE)) {
/* nutrition only if there can be a corpse */
u.uhunger += (mdef->data->cnutrit+1) / 2;
} else tmp = 0;
Sprintf(msgbuf, "You totally digest %s.",
mon_nam(mdef));
if (tmp != 0) {
/* setting afternmv = end_engulf is tempting,
* but will cause problems if the player is
* attacked (which uses his real location) or
* if his See_invisible wears off
*/
You("digest %s.", mon_nam(mdef));
if (Slow_digestion) tmp *= 2;
nomul(-tmp);
nomovemsg = msgbuf;
} else pline("%s", msgbuf);
if (mdef->data == &mons[PM_GREEN_SLIME]) {
Sprintf(msgbuf, "%s isn't sitting well with you.",
The(mdef->data->mname));
if (!Unchanging) {
Slimed = 5L;
flags.botl = 1;
}
} else
exercise(A_CON, TRUE);
}
end_engulf();
return(2);
case AD_PHYS:
if (youmonst.data == &mons[PM_FOG_CLOUD]) {
pline("%s is laden with your moisture.",
Monnam(mdef));
if (amphibious(mdef->data) &&
!flaming(mdef->data)) {
dam = 0;
pline("%s seems unharmed.", Monnam(mdef));
}
} else
pline("%s is pummeled with your debris!",
Monnam(mdef));
break;
case AD_ACID:
pline("%s is covered with your goo!", Monnam(mdef));
if (resists_acid(mdef)) {
pline("It seems harmless to %s.", mon_nam(mdef));
dam = 0;
}
break;
case AD_BLND:
if (can_blnd(&youmonst, mdef, mattk->aatyp, (struct obj *)0)) {
if (mdef->mcansee)
pline("%s can't see in there!", Monnam(mdef));
mdef->mcansee = 0;
dam += mdef->mblinded;
if (dam > 127) dam = 127;
mdef->mblinded = dam;
}
dam = 0;
break;
case AD_ELEC:
if (rn2(2)) {
pline_The("air around %s crackles with electricity.", mon_nam(mdef));
if (resists_elec(mdef)) {
pline("%s seems unhurt.", Monnam(mdef));
dam = 0;
}
golemeffects(mdef,(int)mattk->adtyp,dam);
} else dam = 0;
break;
case AD_COLD:
if (rn2(2)) {
if (resists_cold(mdef)) {
pline("%s seems mildly chilly.", Monnam(mdef));
dam = 0;
} else
pline("%s is freezing to death!",Monnam(mdef));
golemeffects(mdef,(int)mattk->adtyp,dam);
} else dam = 0;
break;
case AD_FIRE:
if (rn2(2)) {
if (resists_fire(mdef)) {
pline("%s seems mildly hot.", Monnam(mdef));
dam = 0;
} else
pline("%s is burning to a crisp!",Monnam(mdef));
golemeffects(mdef,(int)mattk->adtyp,dam);
} else dam = 0;
break;
}
end_engulf();
if ((mdef->mhp -= dam) <= 0) {
killed(mdef);
if (mdef->mhp <= 0) /* not lifesaved */
return(2);
}
You("%s %s!", is_animal(youmonst.data) ? "regurgitate"
: "expel", mon_nam(mdef));
if (Slow_digestion || is_animal(youmonst.data)) {
pline("Obviously, you didn't like %s taste.",
s_suffix(mon_nam(mdef)));
}
} else {
char kbuf[BUFSZ];
You("bite into %s.", mon_nam(mdef));
Sprintf(kbuf, "swallowing %s whole", an(mdef->data->mname));
instapetrify(kbuf);
}
}
return(0);
}
void
missum(mdef,mattk)
register struct monst *mdef;
register struct attack *mattk;
{
if (could_seduce(&youmonst, mdef, mattk))
You("pretend to be friendly to %s.", mon_nam(mdef));
else if(canspotmon(mdef) && flags.verbose)
You("miss %s.", mon_nam(mdef));
else
You("miss it.");
if (!mdef->msleeping && mdef->mcanmove)
wakeup(mdef);
}
STATIC_OVL boolean
hmonas(mon, tmp) /* attack monster as a monster. */
register struct monst *mon;
register int tmp;
{
struct attack *mattk, alt_attk;
int i, sum[NATTK], hittmp = 0;
int nsum = 0;
int dhit = 0;
for(i = 0; i < NATTK; i++) {
sum[i] = 0;
mattk = getmattk(youmonst.data, i, sum, &alt_attk);
switch(mattk->aatyp) {
case AT_WEAP:
use_weapon:
/* Certain monsters don't use weapons when encountered as enemies,
* but players who polymorph into them have hands or claws and thus
* should be able to use weapons. This shouldn't prohibit the use
* of most special abilities, either.
*/
/* Potential problem: if the monster gets multiple weapon attacks,
* we currently allow the player to get each of these as a weapon
* attack. Is this really desirable?
*/
if (uwep) {
hittmp = hitval(uwep, mon);
hittmp += weapon_hit_bonus(uwep);
tmp += hittmp;
}
dhit = (tmp > (dieroll = rnd(20)) || u.uswallow);
/* KMH -- Don't accumulate to-hit bonuses */
if (uwep) tmp -= hittmp;
/* Enemy dead, before any special abilities used */
if (!known_hitum(mon,&dhit,mattk)) {
sum[i] = 2;
break;
} else sum[i] = dhit;
/* might be a worm that gets cut in half */
if (m_at(u.ux+u.dx, u.uy+u.dy) != mon) return((boolean)(nsum != 0));
/* Do not print "You hit" message, since known_hitum
* already did it.
*/
if (dhit && mattk->adtyp != AD_SPEL
&& mattk->adtyp != AD_PHYS)
sum[i] = damageum(mon,mattk);
break;
case AT_CLAW:
if (i==0 && uwep && !cantwield(youmonst.data)) goto use_weapon;
#ifdef SEDUCE
/* succubi/incubi are humanoid, but their _second_
* attack is AT_CLAW, not their first...
*/
if (i==1 && uwep && (u.umonnum == PM_SUCCUBUS ||
u.umonnum == PM_INCUBUS)) goto use_weapon;
#endif
case AT_KICK:
case AT_BITE:
case AT_STNG:
case AT_TUCH:
case AT_BUTT:
case AT_TENT:
if (i==0 && uwep && (youmonst.data->mlet==S_LICH)) goto use_weapon;
if ((dhit = (tmp > rnd(20) || u.uswallow)) != 0) {
int compat;
if (!u.uswallow &&
(compat=could_seduce(&youmonst, mon, mattk))) {
You("%s %s %s.",
mon->mcansee && haseyes(mon->data)
? "smile at" : "talk to",
mon_nam(mon),
compat == 2 ? "engagingly":"seductively");
/* doesn't anger it; no wakeup() */
sum[i] = damageum(mon, mattk);
break;
}
wakeup(mon);
/* maybe this check should be in damageum()? */
if (mon->data == &mons[PM_SHADE] &&
!(mattk->aatyp == AT_KICK &&
uarmf && uarmf->blessed)) {
Your("attack passes harmlessly through %s.",
mon_nam(mon));
break;
}
if (mattk->aatyp == AT_KICK)
You("kick %s.", mon_nam(mon));
else if (mattk->aatyp == AT_BITE)
You("bite %s.", mon_nam(mon));
else if (mattk->aatyp == AT_STNG)
You("sting %s.", mon_nam(mon));
else if (mattk->aatyp == AT_BUTT)
You("butt %s.", mon_nam(mon));
else if (mattk->aatyp == AT_TUCH)
You("touch %s.", mon_nam(mon));
else if (mattk->aatyp == AT_TENT)
Your("tentacles suck %s.", mon_nam(mon));
else You("hit %s.", mon_nam(mon));
sum[i] = damageum(mon, mattk);
} else
missum(mon, mattk);
break;
case AT_HUGS:
/* automatic if prev two attacks succeed, or if
* already grabbed in a previous attack
*/
dhit = 1;
wakeup(mon);
if (mon->data == &mons[PM_SHADE])
Your("hug passes harmlessly through %s.",
mon_nam(mon));
else if (!sticks(mon->data) && !u.uswallow) {
if (mon==u.ustuck) {
pline("%s is being %s.", Monnam(mon),
u.umonnum==PM_ROPE_GOLEM ? "choked":
"crushed");
sum[i] = damageum(mon, mattk);
} else if(i >= 2 && sum[i-1] && sum[i-2]) {
You("grab %s!", mon_nam(mon));
u.ustuck = mon;
sum[i] = damageum(mon, mattk);
}
}
break;
case AT_EXPL: /* automatic hit if next to */
dhit = -1;
wakeup(mon);
sum[i] = explum(mon, mattk);
break;
case AT_ENGL:
if((dhit = (tmp > rnd(20+i)))) {
wakeup(mon);
if (mon->data == &mons[PM_SHADE])
Your("attempt to surround %s is harmless.",
mon_nam(mon));
else {
sum[i]= gulpum(mon,mattk);
if (sum[i] == 2 &&
(mon->data->mlet == S_ZOMBIE ||
mon->data->mlet == S_MUMMY) &&
rn2(5) &&
!Sick_resistance) {
You_feel("%ssick.",
(Sick) ? "very " : "");
mdamageu(mon, rnd(8));
}
}
} else
missum(mon, mattk);
break;
case AT_MAGC:
/* No check for uwep; if wielding nothing we want to
* do the normal 1-2 points bare hand damage...
*/
if (i==0 && (youmonst.data->mlet==S_KOBOLD
|| youmonst.data->mlet==S_ORC
|| youmonst.data->mlet==S_GNOME
)) goto use_weapon;
case AT_NONE:
case AT_BOOM:
continue;
/* Not break--avoid passive attacks from enemy */
case AT_BREA:
case AT_SPIT:
case AT_GAZE: /* all done using #monster command */
dhit = 0;
break;
default: /* Strange... */
impossible("strange attack of yours (%d)",
mattk->aatyp);
}
if (dhit == -1) {
u.mh = -1; /* dead in the current form */
rehumanize();
}
if (sum[i] == 2)
return((boolean)passive(mon, 1, 0, mattk->aatyp));
/* defender dead */
else {
(void) passive(mon, sum[i], 1, mattk->aatyp);
nsum |= sum[i];
}
if (!Upolyd)
break; /* No extra attacks if no longer a monster */
if (multi < 0)
break; /* If paralyzed while attacking, i.e. floating eye */
}
return((boolean)(nsum != 0));
}
/* Special (passive) attacks on you by monsters done here. */
int
passive(mon, mhit, malive, aatyp)
register struct monst *mon;
register boolean mhit;
register int malive;
uchar aatyp;
{
register struct permonst *ptr = mon->data;
register int i, tmp;
for(i = 0; ; i++) {
if(i >= NATTK) return(malive | mhit); /* no passive attacks */
if(ptr->mattk[i].aatyp == AT_NONE) break; /* try this one */
}
/* Note: tmp not always used */
if (ptr->mattk[i].damn)
tmp = d((int)ptr->mattk[i].damn, (int)ptr->mattk[i].damd);
else if(ptr->mattk[i].damd)
tmp = d((int)mon->m_lev+1, (int)ptr->mattk[i].damd);
else
tmp = 0;
/* These affect you even if they just died */
switch(ptr->mattk[i].adtyp) {
case AD_ACID:
if(mhit && rn2(2)) {
if (Blind || !flags.verbose) You("are splashed!");
else You("are splashed by %s acid!",
s_suffix(mon_nam(mon)));
if (!Acid_resistance)
mdamageu(mon, tmp);
if(!rn2(30)) erode_armor(&youmonst, TRUE);
}
if (mhit) {
if (aatyp == AT_KICK) {
if (uarmf && !rn2(6))
(void)rust_dmg(uarmf, xname(uarmf), 3, TRUE, &youmonst);
} else if (aatyp == AT_WEAP || aatyp == AT_CLAW ||
aatyp == AT_MAGC || aatyp == AT_TUCH)
passive_obj(mon, (struct obj*)0, &(ptr->mattk[i]));
}
exercise(A_STR, FALSE);
break;
case AD_STON:
if (mhit) { /* successful attack */
long protector = attk_protection((int)aatyp);
/* hero using monsters' AT_MAGC attack is hitting hand to
hand rather than casting a spell */
if (aatyp == AT_MAGC) protector = W_ARMG;
if (protector == 0L || /* no protection */
(protector == W_ARMG && !uarmg && !uwep) ||
(protector == W_ARMF && !uarmf) ||
(protector == W_ARMH && !uarmh) ||
(protector == (W_ARMC|W_ARMG) && (!uarmc || !uarmg))) {
if (!Stone_resistance &&
!(poly_when_stoned(youmonst.data) &&
polymon(PM_STONE_GOLEM))) {
You("turn to stone...");
done_in_by(mon);
return 2;
}
}
}
break;
case AD_RUST:
if(mhit && !mon->mcan) {
if (aatyp == AT_KICK) {
if (uarmf)
(void)rust_dmg(uarmf, xname(uarmf), 1, TRUE, &youmonst);
} else if (aatyp == AT_WEAP || aatyp == AT_CLAW ||
aatyp == AT_MAGC || aatyp == AT_TUCH)
passive_obj(mon, (struct obj*)0, &(ptr->mattk[i]));
}
break;
case AD_CORR:
if(mhit && !mon->mcan) {
if (aatyp == AT_KICK) {
if (uarmf)
(void)rust_dmg(uarmf, xname(uarmf), 3, TRUE, &youmonst);
} else if (aatyp == AT_WEAP || aatyp == AT_CLAW ||
aatyp == AT_MAGC || aatyp == AT_TUCH)
passive_obj(mon, (struct obj*)0, &(ptr->mattk[i]));
}
break;
case AD_MAGM:
/* wrath of gods for attacking Oracle */
if(Antimagic) {
shieldeff(u.ux, u.uy);
pline("A hail of magic missiles narrowly misses you!");
} else {
You("are hit by magic missiles appearing from thin air!");
mdamageu(mon, tmp);
}
break;
case AD_ENCH: /* KMH -- remove enchantment (disenchanter) */
if (mhit) {
struct obj *obj = (struct obj *)0;
if (aatyp == AT_KICK) {
obj = uarmf;
if (!obj) break;
} else if (aatyp == AT_BITE || aatyp == AT_BUTT ||
(aatyp >= AT_STNG && aatyp < AT_WEAP)) {
break; /* no object involved */
}
passive_obj(mon, obj, &(ptr->mattk[i]));
}
break;
default:
break;
}
/* These only affect you if they still live */
if(malive && !mon->mcan && rn2(3)) {
switch(ptr->mattk[i].adtyp) {
case AD_PLYS:
if(ptr == &mons[PM_FLOATING_EYE]) {
if (!canseemon(mon)) {
break;
}
if(mon->mcansee) {
if (ureflects("%s gaze is reflected by your %s.",
s_suffix(Monnam(mon))))
;
else if (Free_action)
You("momentarily stiffen under %s gaze!",
s_suffix(mon_nam(mon)));
else {
You("are frozen by %s gaze!",
s_suffix(mon_nam(mon)));
nomul((ACURR(A_WIS) > 12 || rn2(4)) ? -tmp : -127);
}
} else {
pline("%s cannot defend itself.",
Adjmonnam(mon,"blind"));
if(!rn2(500)) change_luck(-1);
}
} else if (Free_action) {
You("momentarily stiffen.");
} else { /* gelatinous cube */
You("are frozen by %s!", mon_nam(mon));
nomovemsg = 0; /* default: "you can move again" */
nomul(-tmp);
exercise(A_DEX, FALSE);
}
break;
case AD_COLD: /* brown mold or blue jelly */
if(monnear(mon, u.ux, u.uy)) {
if(Cold_resistance) {
shieldeff(u.ux, u.uy);
You_feel("a mild chill.");
ugolemeffects(AD_COLD, tmp);
break;
}
You("are suddenly very cold!");
mdamageu(mon, tmp);
/* monster gets stronger with your heat! */
mon->mhp += tmp / 2;
if (mon->mhpmax < mon->mhp) mon->mhpmax = mon->mhp;
/* at a certain point, the monster will reproduce! */
if(mon->mhpmax > ((int) (mon->m_lev+1) * 8))
(void)split_mon(mon, &youmonst);
}
break;
case AD_STUN: /* specifically yellow mold */
if(!Stunned)
make_stunned((long)tmp, TRUE);
break;
case AD_FIRE:
if(monnear(mon, u.ux, u.uy)) {
if(Fire_resistance) {
shieldeff(u.ux, u.uy);
You_feel("mildly warm.");
ugolemeffects(AD_FIRE, tmp);
break;
}
You("are suddenly very hot!");
mdamageu(mon, tmp);
}
break;
case AD_ELEC:
if(Shock_resistance) {
shieldeff(u.ux, u.uy);
You_feel("a mild tingle.");
ugolemeffects(AD_ELEC, tmp);
break;
}
You("are jolted with electricity!");
mdamageu(mon, tmp);
break;
default:
break;
}
}
return(malive | mhit);
}
/*
* Special (passive) attacks on an attacking object by monsters done here.
* Assumes the attack was successful.
*/
void
passive_obj(mon, obj, mattk)
register struct monst *mon;
register struct obj *obj; /* null means pick uwep, uswapwep or uarmg */
struct attack *mattk; /* null means we find one internally */
{
register struct permonst *ptr = mon->data;
register int i;
/* if caller hasn't specified an object, use uwep, uswapwep or uarmg */
if (!obj) {
obj = (u.twoweap && uswapwep && !rn2(2)) ? uswapwep : uwep;
if (!obj && mattk->adtyp == AD_ENCH)
obj = uarmg; /* no weapon? then must be gloves */
if (!obj) return; /* no object to affect */
}
/* if caller hasn't specified an attack, find one */
if (!mattk) {
for(i = 0; ; i++) {
if(i >= NATTK) return; /* no passive attacks */
if(ptr->mattk[i].aatyp == AT_NONE) break; /* try this one */
}
mattk = &(ptr->mattk[i]);
}
switch(mattk->adtyp) {
case AD_ACID:
if(!rn2(6)) {
erode_obj(obj, TRUE, FALSE);
}
break;
case AD_RUST:
if(!mon->mcan) {
erode_obj(obj, FALSE, FALSE);
}
break;
case AD_CORR:
if(!mon->mcan) {
erode_obj(obj, TRUE, FALSE);
}
break;
case AD_ENCH:
if (!mon->mcan) {
if (drain_item(obj) && carried(obj) &&
(obj->known || obj->oclass == ARMOR_CLASS)) {
Your("%s less effective.", aobjnam(obj, "seem"));
}
break;
}
default:
break;
}
if (carried(obj)) update_inventory();
}
/* Note: caller must ascertain mtmp is mimicking... */
void
stumble_onto_mimic(mtmp)
struct monst *mtmp;
{
const char *fmt = "Wait! That's %s!",
*generic = "a monster",
*what = 0;
if(!u.ustuck && !mtmp->mflee && dmgtype(mtmp->data,AD_STCK))
u.ustuck = mtmp;
if (Blind) {
if (!Blind_telepat)
what = generic; /* with default fmt */
else if (mtmp->m_ap_type == M_AP_MONSTER)
what = a_monnam(mtmp); /* differs from what was sensed */
} else {
int glyph = levl[u.ux+u.dx][u.uy+u.dy].glyph;
if (glyph_is_cmap(glyph) &&
(glyph_to_cmap(glyph) == S_hcdoor ||
glyph_to_cmap(glyph) == S_vcdoor))
fmt = "The door actually was %s!";
else if (glyph_is_object(glyph) &&
glyph_to_obj(glyph) == GOLD_PIECE)
fmt = "That gold was %s!";
/* cloned Wiz starts out mimicking some other monster and
might make himself invisible before being revealed */
if (mtmp->minvis && !See_invisible)
what = generic;
else
what = a_monnam(mtmp);
}
if (what) pline(fmt, what);
wakeup(mtmp); /* clears mimicking */
}
STATIC_OVL void
nohandglow(mon)
struct monst *mon;
{
char *hands=makeplural(body_part(HAND));
if (!u.umconf || mon->mconf) return;
if (u.umconf == 1) {
if (Blind)
Your("%s stop tingling.", hands);
else
Your("%s stop glowing %s.", hands, hcolor(NH_RED));
} else {
if (Blind)
pline_The("tingling in your %s lessens.", hands);
else
Your("%s no longer glow so brightly %s.", hands,
hcolor(NH_RED));
}
u.umconf--;
}
int
flash_hits_mon(mtmp, otmp)
struct monst *mtmp;
struct obj *otmp; /* source of flash */
{
int tmp, amt, res = 0, useeit = canseemon(mtmp);
if (mtmp->msleeping) {
mtmp->msleeping = 0;
if (useeit) {
pline_The("flash awakens %s.", mon_nam(mtmp));
res = 1;
}
} else if (mtmp->data->mlet != S_LIGHT) {
if (!resists_blnd(mtmp)) {
tmp = dist2(otmp->ox, otmp->oy, mtmp->mx, mtmp->my);
if (useeit) {
pline("%s is blinded by the flash!", Monnam(mtmp));
res = 1;
}
if (mtmp->data == &mons[PM_GREMLIN]) {
/* Rule #1: Keep them out of the light. */
amt = otmp->otyp == WAN_LIGHT ? d(1 + otmp->spe, 4) :
rn2(min(mtmp->mhp,4));
pline("%s %s!", Monnam(mtmp), amt > mtmp->mhp / 2 ?
"wails in agony" : "cries out in pain");
if ((mtmp->mhp -= amt) <= 0) {
if (flags.mon_moving)
monkilled(mtmp, (char *)0, AD_BLND);
else
killed(mtmp);
} else if (cansee(mtmp->mx,mtmp->my) && !canspotmon(mtmp)){
map_invisible(mtmp->mx, mtmp->my);
}
}
if (mtmp->mhp > 0) {
if (!flags.mon_moving) setmangry(mtmp);
if (tmp < 9 && !mtmp->isshk && rn2(4)) {
if (rn2(4))
monflee(mtmp, rnd(100), FALSE, TRUE);
else
monflee(mtmp, 0, FALSE, TRUE);
}
mtmp->mcansee = 0;
mtmp->mblinded = (tmp < 3) ? 0 : rnd(1 + 50/tmp);
}
}
}
return res;
}
/*uhitm.c*/
|