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

Function thitu

src/mthrowu.c:74–155  ·  view source on GitHub ↗

hero is hit by something other than a monster (though it could be a missile thrown or shot by a monster) */

Source from the content-addressed store, hash-verified

72/* hero is hit by something other than a monster (though it could be a
73 missile thrown or shot by a monster) */
74int
75thitu(
76 int tlev, /* pseudo-level used when deciding whether to hit hero's AC */
77 int dam,
78 struct obj **objp,
79 const char *name) /* if null, then format `*objp' */
80{
81 struct obj *obj = objp ? *objp : 0;
82 const char *onm, *knm;
83 boolean is_acid, named = (name != 0);
84 int kprefix = KILLED_BY_AN, dieroll;
85 char onmbuf[BUFSZ], knmbuf[BUFSZ];
86
87 if (!name) {
88 if (!obj)
89 panic("thitu: name & obj both null?");
90 name = strcpy(onmbuf,
91 (obj->quan > 1L) ? doname(obj) : mshot_xname(obj));
92 knm = strcpy(knmbuf, killer_xname(obj));
93 kprefix = KILLED_BY; /* killer_name supplies "an" if warranted */
94 } else {
95 knm = name;
96 /* [perhaps ought to check for plural here too] */
97 if (!strncmpi(name, "the ", 4) || !strncmpi(name, "an ", 3)
98 || !strncmpi(name, "a ", 2))
99 kprefix = KILLED_BY;
100 }
101 onm = (obj && obj_is_pname(obj)) ? the(name)
102 : (obj && obj->quan > 1L) ? name
103 : an(name);
104 is_acid = (obj && obj->otyp == ACID_VENOM);
105
106 if (u.uac + tlev <= (dieroll = rnd(20))) {
107 ++gm.mesg_given;
108 if (Blind || !flags.verbose) {
109 pline("It misses.");
110 } else if (u.uac + tlev <= dieroll - 2) {
111 if (onm != onmbuf)
112 Strcpy(onmbuf, onm); /* [modifiable buffer for upstart()] */
113 pline("%s %s you.", upstart(onmbuf), vtense(onmbuf, "miss"));
114 } else
115 You("are almost hit by %s.", onm);
116 return 0;
117 } else {
118 if (Blind || !flags.verbose)
119 You("are hit%s", exclam(dam));
120 else
121 You("are hit by %s%s", onm, exclam(dam));
122
123 if (is_acid && Acid_resistance) {
124 pline("It doesn't seem to hurt you.");
125 monstseesu(M_SEEN_ACID);
126 } else if (obj && stone_missile(obj)
127 && passes_rocks(gy.youmonst.data)) {
128 /* use 'named' as an approximation for "hitting from above";
129 we avoid "passes through you" for horizontal flight path
130 because missile stops and that wording would suggest that
131 it should keep going */

Callers 8

trapeffect_arrow_trapFunction · 0.85
trapeffect_dart_trapFunction · 0.85
launch_objFunction · 0.85
boomhitFunction · 0.85
mthrowu.cFile · 0.85
thrwmuFunction · 0.85
use_whipFunction · 0.85
scatterFunction · 0.85

Calls 15

donameFunction · 0.85
mshot_xnameFunction · 0.85
killer_xnameFunction · 0.85
obj_is_pnameFunction · 0.85
theFunction · 0.85
anFunction · 0.85
rndFunction · 0.85
upstartFunction · 0.85
vtenseFunction · 0.85
YouFunction · 0.85
exclamFunction · 0.85
monstseesuFunction · 0.85

Tested by

no test coverage detected