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

Function new_were

src/were.c:95–138  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

93}
94
95void
96new_were(struct monst *mon)
97{
98 int pm;
99
100 /* neither hero nor werecreature can change from human form to
101 critter form if hero has Protection_from_shape_changers extrinsic;
102 if already in critter form, always change to human form for that */
103 if (Protection_from_shape_changers && is_human(mon->data))
104 return;
105
106 pm = counter_were(monsndx(mon->data));
107 if (pm < LOW_PM) {
108 impossible("unknown lycanthrope %s.",
109 mon->data->pmnames[NEUTRAL]);
110 return;
111 }
112
113 if (canseemon(mon) && !Hallucination)
114 pline("%s changes into a %s.", Monnam(mon),
115 is_human(&mons[pm]) ? "human"
116 /* pmname()+4: skip past "were" prefix */
117 : pmname(&mons[pm], Mgender(mon)) + 4);
118
119 set_mon_data(mon, &mons[pm]);
120 if (helpless(mon)) {
121 /* transformation wakens and/or revitalizes */
122 mon->msleeping = 0;
123 mon->mfrozen = 0; /* not asleep or paralyzed */
124 mon->mcanmove = 1;
125 }
126 /* regenerate by 1/4 of the lost hit points */
127 healmon(mon, (mon->mhpmax - mon->mhp) / 4, 0);
128 newsym(mon->mx, mon->my);
129 mon_break_armor(mon, FALSE);
130 possibly_unwield(mon, FALSE);
131
132 /* vision capability isn't changing so we don't call set_apparxy() to
133 update mon's idea of where hero is; peaceful check is redundant */
134 if (svc.context.mon_moving && !mon->mpeaceful
135 && onscary(mon->mux, mon->muy, mon)
136 && monnear(mon, mon->mux, mon->muy))
137 monflee(mon, rn1(9, 2), TRUE, TRUE); /* 2..10 turns */
138}
139
140/* were-creature (even you) summons a horde */
141int

Callers 4

potionhitFunction · 0.85
were_changeFunction · 0.85
normal_shapeFunction · 0.85
summonmuFunction · 0.85

Calls 15

counter_wereFunction · 0.85
canseemonFunction · 0.85
MonnamFunction · 0.85
pmnameFunction · 0.85
MgenderFunction · 0.85
set_mon_dataFunction · 0.85
healmonFunction · 0.85
newsymFunction · 0.85
mon_break_armorFunction · 0.85
possibly_unwieldFunction · 0.85
onscaryFunction · 0.85
monnearFunction · 0.85

Tested by

no test coverage detected