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

Function select_newcham_form

src/mon.c:5156–5225  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5154}
5155
5156int
5157select_newcham_form(struct monst *mon)
5158{
5159 int mndx = NON_PM, tryct;
5160
5161 switch (mon->cham) {
5162 case PM_SANDESTIN:
5163 if (rn2(7))
5164 mndx = pick_nasty(mons[PM_ARCHON].difficulty - 1);
5165 break;
5166 case PM_DOPPELGANGER:
5167 if (!rn2(7)) {
5168 mndx = pick_nasty(mons[PM_JABBERWOCK].difficulty - 1);
5169 } else if (rn2(3)) { /* role monsters */
5170 mndx = tt_doppel(mon);
5171 } else if (!rn2(3)) { /* quest guardians */
5172 mndx = rn1(PM_APPRENTICE - PM_STUDENT + 1, PM_STUDENT);
5173 /* avoid own role's guardian */
5174 if (mndx == gu.urole.guardnum)
5175 mndx = NON_PM;
5176 } else { /* general humanoids */
5177 tryct = 5;
5178 do {
5179 mndx = rn1(SPECIAL_PM - LOW_PM, LOW_PM);
5180 /* assert(ismnum(mndx)); */
5181 if (humanoid(&mons[mndx]) && polyok(&mons[mndx]))
5182 break;
5183 } while (--tryct > 0);
5184 if (!tryct)
5185 mndx = NON_PM;
5186 }
5187 break;
5188 case PM_CHAMELEON:
5189 if (!rn2(3))
5190 mndx = pick_animal();
5191 break;
5192 case PM_VLAD_THE_IMPALER:
5193 case PM_VAMPIRE_LEADER:
5194 case PM_VAMPIRE:
5195 mndx = pickvampshape(mon);
5196 break;
5197 case NON_PM: /* ordinary */
5198 {
5199 struct obj *m_armr = which_armor(mon, W_ARM);
5200
5201 if (m_armr && Is_dragon_scales(m_armr))
5202 mndx = (int) (Dragon_scales_to_pm(m_armr) - mons);
5203 else if (m_armr && Is_dragon_mail(m_armr))
5204 mndx = (int) (Dragon_mail_to_pm(m_armr) - mons);
5205 }
5206 break;
5207 }
5208
5209 /* for debugging: allow control of polymorphed monster */
5210 if (wizard && iflags.mon_polycontrol)
5211 mndx = wiz_force_cham_form(mon);
5212
5213 /* if no form was specified above, pick one at random now */

Callers 2

newchamFunction · 0.85
create_monsterFunction · 0.85

Calls 9

rn2Function · 0.85
pick_nastyFunction · 0.85
tt_doppelFunction · 0.85
pick_animalFunction · 0.85
pickvampshapeFunction · 0.85
which_armorFunction · 0.85
wiz_force_cham_formFunction · 0.85
validspecmonFunction · 0.85
isupperFunction · 0.85

Tested by

no test coverage detected