MCPcopy Create free account
hub / github.com/crawl/crawl / polymorph

Method polymorph

crawl-ref/source/player.cc:7980–8021  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7978}
7979
7980bool player::polymorph(int dur)
7981{
7982 ASSERT(!crawl_state.game_is_arena());
7983
7984 if (!can_polymorph())
7985 return false;
7986
7987 transformation f = transformation::none;
7988
7989 vector<transformation> forms = {
7990 transformation::bat,
7991 transformation::wisp,
7992 };
7993
7994 // Don't polymorph the player into something that would require emergency flight.
7995 if (!feat_dangerous_for_form(transformation::pig, env.grid(you.pos())))
7996 forms.emplace_back(transformation::pig);
7997 if (!feat_dangerous_for_form(transformation::tree, env.grid(you.pos())))
7998 forms.emplace_back(transformation::tree);
7999 if (!feat_dangerous_for_form(transformation::fungus, env.grid(you.pos())))
8000 forms.emplace_back(transformation::fungus);
8001
8002 for (int tries = 0; tries < 3; tries++)
8003 {
8004 f = forms[random2(forms.size())];
8005
8006 // need to do a dry run first, as Zin's protection has a random factor
8007 if (cant_transform_reason(f, true).empty())
8008 break;
8009
8010 f = transformation::none;
8011 }
8012
8013 if (f != transformation::none && transform(dur, f, true))
8014 {
8015 stop_delay(true, true);
8016
8017 transform_uncancellable = true;
8018 return true;
8019 }
8020 return false;
8021}
8022
8023// Inflict some amount of Doom on the player. Returns true if this was enough
8024// to cause a Bane to be inflicted.

Callers 5

_degeneration_cardFunction · 0.45
_xom_polymorph_monsterFunction · 0.45

Calls 10

feat_dangerous_for_formFunction · 0.85
random2Function · 0.85
cant_transform_reasonFunction · 0.85
transformFunction · 0.85
stop_delayFunction · 0.85
game_is_arenaMethod · 0.80
gridMethod · 0.80
posMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected