MCPcopy Create free account
hub / github.com/NetHack/NetHack / make_sick

Function make_sick

src/potion.c:136–192  ·  view source on GitHub ↗

Sick is overloaded with both fatal illness and food poisoning (via u.usick_type bit mask), but delayed killer can only support one or the other at a time. They should become separate intrinsics.... */

Source from the content-addressed store, hash-verified

134 u.usick_type bit mask), but delayed killer can only support one or
135 the other at a time. They should become separate intrinsics.... */
136void
137make_sick(long xtime,
138 const char *cause, /* sickness cause */
139 boolean talk,
140 int type)
141{
142 struct kinfo *kptr;
143 long old = Sick;
144
145#if 0 /* tell player even if hero is unconscious */
146 if (Unaware)
147 talk = FALSE;
148#endif
149 if (xtime > 0L) {
150 if (Sick_resistance)
151 return;
152 if (!old) {
153 /* newly sick */
154 You_feel("deathly sick.");
155 } else {
156 /* already sick */
157 if (talk)
158 You_feel("%s worse.", xtime <= Sick / 2L ? "much" : "even");
159 }
160 set_itimeout(&Sick, xtime);
161 u.usick_type |= type;
162 disp.botl = TRUE;
163 } else if (old && (type & u.usick_type)) {
164 /* was sick, now not */
165 u.usick_type &= ~type;
166 if (u.usick_type) { /* only partly cured */
167 if (talk)
168 You_feel("somewhat better.");
169 set_itimeout(&Sick, Sick * 2); /* approximation */
170 } else {
171 if (talk)
172 You_feel("cured. What a relief!");
173 Sick = 0L; /* set_itimeout(&Sick, 0L) */
174 }
175 disp.botl = TRUE;
176 }
177
178 kptr = find_delayed_killer(SICK);
179 if (Sick) {
180 exercise(A_CON, FALSE);
181 /* setting delayed_killer used to be unconditional, but that's
182 not right when make_sick(0) is called to cure food poisoning
183 if hero was also fatally ill; this is only approximate */
184 if (xtime || !old || !kptr) {
185 int kpfx = ((cause && !strcmp(cause, "#wizintrinsic"))
186 ? KILLED_BY : KILLED_BY_AN);
187
188 delayed_killer(SICK, kpfx, cause);
189 }
190 } else
191 dealloc_killer(kptr);
192}
193

Callers 15

savelifeFunction · 0.85
throne_sit_effectFunction · 0.85
peffect_waterFunction · 0.85
healupFunction · 0.85
mhitm_ad_healFunction · 0.85
invoke_healingFunction · 0.85
nh_timeoutFunction · 0.85
fix_worst_troubleFunction · 0.85
wiz_intrinsicFunction · 0.85
newmanFunction · 0.85
polymonFunction · 0.85
eatcorpseFunction · 0.85

Calls 6

You_feelFunction · 0.85
set_itimeoutFunction · 0.85
find_delayed_killerFunction · 0.85
exerciseFunction · 0.85
delayed_killerFunction · 0.85
dealloc_killerFunction · 0.85

Tested by

no test coverage detected