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

Function pickvampshape

src/mon.c:4940–4979  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4938}
4939
4940staticfn int
4941pickvampshape(struct monst *mon)
4942{
4943 int mndx = mon->cham, wolfchance = 10;
4944 /* avoid picking monsters with lowercase display symbols ('d' for wolf
4945 and 'v' for fog cloud) on rogue level*/
4946 boolean uppercase_only = Is_rogue_level(&u.uz);
4947
4948 switch (mndx) {
4949 case PM_VLAD_THE_IMPALER:
4950 /* ensure Vlad can keep carrying the Candelabrum */
4951 if (mon_has_special(mon))
4952 break; /* leave mndx as is */
4953 wolfchance = 3;
4954 FALLTHROUGH;
4955 /*FALLTHRU*/
4956 case PM_VAMPIRE_LEADER: /* vampire lord or Vlad can become wolf */
4957 if (!rn2(wolfchance) && !uppercase_only
4958 /* don't pick a walking form if that would lead to immediate
4959 drowning or immolation and reversion to vampire form */
4960 && !is_pool_or_lava(mon->mx, mon->my)) {
4961 mndx = PM_WOLF;
4962 break;
4963 }
4964 FALLTHROUGH;
4965 /*FALLTHRU*/
4966 case PM_VAMPIRE: /* any vampire can become fog or bat */
4967 mndx = (!rn2(4) && !uppercase_only) ? PM_FOG_CLOUD : PM_VAMPIRE_BAT;
4968 break;
4969 }
4970
4971 /* return to base form if chosen poly target has been genocided
4972 or randomly if already in an alternate form (to prevent always
4973 switching back and forth between bat and fog) */
4974 if ((svm.mvitals[mndx].mvflags & G_GENOD) != 0
4975 || (mon->data != &mons[mon->cham] && !rn2(4)))
4976 return mon->cham;
4977
4978 return mndx;
4979}
4980
4981/* nonshapechangers who warrant special polymorph handling */
4982staticfn boolean

Callers 3

decide_to_shapeshiftFunction · 0.85
wiz_force_cham_formFunction · 0.85
select_newcham_formFunction · 0.85

Calls 3

mon_has_specialFunction · 0.85
rn2Function · 0.85
is_pool_or_lavaFunction · 0.85

Tested by

no test coverage detected