MCPcopy Index your code
hub / github.com/NetHack/NetHack / killer_xname

Function killer_xname

src/objnam.c:1941–2005  ·  view source on GitHub ↗

treat an object as fully ID'd when it might be used as reason for death */

Source from the content-addressed store, hash-verified

1939
1940/* treat an object as fully ID'd when it might be used as reason for death */
1941char *
1942killer_xname(struct obj *obj)
1943{
1944 struct obj save_obj;
1945 unsigned save_ocknown;
1946 char *buf, *save_ocuname, *save_oname = (char *) 0;
1947
1948 /* bypass object twiddling for artifacts */
1949 if (obj->oartifact)
1950 return bare_artifactname(obj);
1951
1952 /* remember original settings for core of the object;
1953 oextra structs other than oname don't matter here--since they
1954 aren't modified they don't need to be saved and restored */
1955 save_obj = *obj;
1956 if (has_oname(obj))
1957 save_oname = ONAME(obj);
1958
1959 /* killer name should be more specific than general xname; however, exact
1960 info like blessed/cursed and rustproof makes things be too verbose; set
1961 dknown (not observe_object) because dead characters don't observe */
1962 obj->known = obj->dknown = 1;
1963 obj->bknown = obj->rknown = obj->greased = 0;
1964 /* if character is a priest[ess], bknown will get toggled back on */
1965 if (obj->otyp != POT_WATER)
1966 obj->blessed = obj->cursed = 0;
1967 else
1968 obj->bknown = 1; /* describe holy/unholy water as such */
1969 /* "killed by poisoned <obj>" would be misleading when poison is
1970 not the cause of death and "poisoned by poisoned <obj>" would
1971 be redundant when it is, so suppress "poisoned" prefix */
1972 obj->opoisoned = 0;
1973 /* strip user-supplied name; artifacts keep theirs */
1974 if (!obj->oartifact && save_oname)
1975 ONAME(obj) = (char *) 0;
1976 /* temporarily identify the type of object */
1977 save_ocknown = objects[obj->otyp].oc_name_known;
1978 objects[obj->otyp].oc_name_known = 1;
1979 save_ocuname = objects[obj->otyp].oc_uname;
1980 objects[obj->otyp].oc_uname = 0; /* avoid "foo called bar" */
1981
1982 /* format the object */
1983 if (obj->otyp == CORPSE) {
1984 buf = corpse_xname(obj, (const char *) 0, CXN_NORMAL);
1985 } else if (obj->otyp == SLIME_MOLD) {
1986 /* concession to "most unique deaths competition" in the annual
1987 devnull tournament, suppress player supplied fruit names because
1988 those can be used to fake other objects and dungeon features */
1989 buf = nextobuf();
1990 Sprintf(buf, "deadly slime mold%s", plur(obj->quan));
1991 } else {
1992 buf = xname(obj);
1993 }
1994 /* apply an article if appropriate; caller should always use KILLED_BY */
1995 if (obj->quan == 1L && !strstri(buf, "'s ") && !strstri(buf, "s' "))
1996 buf = (obj_is_pname(obj) || the_unique_obj(obj)) ? the(buf) : an(buf);
1997
1998 objects[obj->otyp].oc_name_known = save_ocknown;

Callers 13

cant_wield_corpseFunction · 0.85
wielding_corpseFunction · 0.85
retouch_objectFunction · 0.85
throw_objFunction · 0.85
throwitFunction · 0.85
feel_cockatriceFunction · 0.85
fatal_corpse_mistakeFunction · 0.85
chokeFunction · 0.85
dozapFunction · 0.85
kick_objectFunction · 0.85
really_kick_objectFunction · 0.85
thituFunction · 0.85

Calls 9

bare_artifactnameFunction · 0.85
corpse_xnameFunction · 0.85
nextobufFunction · 0.85
xnameFunction · 0.85
strstriFunction · 0.85
obj_is_pnameFunction · 0.85
the_unique_objFunction · 0.85
theFunction · 0.85
anFunction · 0.85

Tested by

no test coverage detected