| 1922 | } |
| 1923 | |
| 1924 | staticfn void |
| 1925 | create_monster(monster *m, struct mkroom *croom) |
| 1926 | { |
| 1927 | struct monst *mtmp; |
| 1928 | coordxy x, y; |
| 1929 | char class; |
| 1930 | unsigned int amask; |
| 1931 | coord cc; |
| 1932 | struct permonst *pm; |
| 1933 | unsigned g_mvflags; |
| 1934 | |
| 1935 | if (m->class >= 0) |
| 1936 | class = (char) def_char_to_monclass((char) m->class); |
| 1937 | else |
| 1938 | class = 0; |
| 1939 | |
| 1940 | if (class == MAXMCLASSES) |
| 1941 | panic("create_monster: unknown monster class '%c'", m->class); |
| 1942 | |
| 1943 | amask = sp_amask_to_amask(m->sp_amask); |
| 1944 | |
| 1945 | if (!class) { |
| 1946 | pm = (struct permonst *) 0; |
| 1947 | } else if (m->id != NON_PM) { |
| 1948 | pm = &mons[m->id]; |
| 1949 | g_mvflags = (unsigned) svm.mvitals[monsndx(pm)].mvflags; |
| 1950 | if ((pm->geno & G_UNIQ) && (g_mvflags & G_EXTINCT)) |
| 1951 | return; |
| 1952 | if (g_mvflags & G_GONE) /* genocided or extinct */ |
| 1953 | pm = (struct permonst *) 0; /* make random monster */ |
| 1954 | } else { |
| 1955 | pm = mkclass(class, G_NOGEN); |
| 1956 | /* if we can't get a specific monster type (pm == 0) then the |
| 1957 | class has been genocided, so settle for a random monster */ |
| 1958 | } |
| 1959 | if (In_mines(&u.uz) && pm && your_race(pm) |
| 1960 | && (Race_if(PM_DWARF) || Race_if(PM_GNOME)) && rn2(3)) |
| 1961 | pm = (struct permonst *) 0; |
| 1962 | |
| 1963 | if (pm) { |
| 1964 | int loc = pm_to_humidity(pm); |
| 1965 | |
| 1966 | /* If water-liking monster, first try is without DRY */ |
| 1967 | get_location_coord(&x, &y, loc | NO_LOC_WARN, croom, m->coord); |
| 1968 | if (x == -1 && y == -1) { |
| 1969 | loc |= DRY; |
| 1970 | get_location_coord(&x, &y, loc, croom, m->coord); |
| 1971 | } |
| 1972 | } else { |
| 1973 | get_location_coord(&x, &y, DRY, croom, m->coord); |
| 1974 | } |
| 1975 | |
| 1976 | /* try to find a close place if someone else is already there */ |
| 1977 | if (MON_AT(x, y) && enexto(&cc, x, y, pm)) |
| 1978 | x = cc.x, y = cc.y; |
| 1979 | |
| 1980 | if (croom && !inside_room(croom, x, y)) |
| 1981 | return; |
no test coverage detected