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

Function eatmupdate

src/eat.c:180–213  ·  view source on GitHub ↗

called when hallucination is toggled */

Source from the content-addressed store, hash-verified

178
179/* called when hallucination is toggled */
180void
181eatmupdate(void)
182{
183 const char *altmsg = 0;
184 int altapp = 0; /* lint suppression */
185
186 if (!ge.eatmbuf || gn.nomovemsg != ge.eatmbuf)
187 return;
188
189 if (is_obj_mappear(&gy.youmonst,ORANGE) && !Hallucination) {
190 /* revert from hallucinatory to "normal" mimicking */
191 altmsg = "You now prefer mimicking yourself.";
192 altapp = GOLD_PIECE;
193 } else if (is_obj_mappear(&gy.youmonst,GOLD_PIECE) && Hallucination) {
194 /* won't happen; anything which might make immobilized
195 hero begin hallucinating (black light attack, theft
196 of Grayswandir) will terminate the mimicry first */
197 altmsg = "Your rind escaped intact.";
198 altapp = ORANGE;
199 }
200
201 if (altmsg) {
202 /* replace end-of-mimicking message */
203 unsigned amlen = Strlen(altmsg);
204 if (amlen > Strlen(ge.eatmbuf)) {
205 free((genericptr_t) ge.eatmbuf);
206 ge.eatmbuf = (char *) alloc(amlen + 1);
207 }
208 gn.nomovemsg = strcpy(ge.eatmbuf, altmsg);
209 /* update current image */
210 gy.youmonst.mappearance = altapp;
211 newsym(u.ux, u.uy);
212 }
213}
214
215/* ``[the(] singular(food, xname) [)]'' */
216staticfn const char *

Callers 1

make_hallucinatedFunction · 0.85

Calls 2

newsymFunction · 0.85
allocFunction · 0.70

Tested by

no test coverage detected