| 7978 | } |
| 7979 | |
| 7980 | bool 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. |
no test coverage detected