* Attempts to transform the player into the specified form. * * If the player is already in that form, attempt to refresh its duration and * power. * * @param dur The duration of the transformation (0 if the * transformation should be permanent.) * @param which_trans The form which the player should become. * @param involuntary Checks for
| 2130 | * Otherwise, false. |
| 2131 | */ |
| 2132 | bool transform(int dur, transformation which_trans, bool involuntary, |
| 2133 | bool using_talisman) |
| 2134 | { |
| 2135 | // Zin's protection. |
| 2136 | if (have_passive(passive_t::resist_polymorph) |
| 2137 | && x_chance_in_y(you.piety(), piety_breakpoint(5)) |
| 2138 | && which_trans != transformation::none) |
| 2139 | { |
| 2140 | simple_god_message(" protects your body from unnatural transformation!"); |
| 2141 | return false; |
| 2142 | } |
| 2143 | |
| 2144 | if (!involuntary && crawl_state.is_god_acting()) |
| 2145 | involuntary = true; |
| 2146 | |
| 2147 | if (!check_transform_into(which_trans, involuntary, |
| 2148 | using_talisman ? you.active_talisman() : nullptr)) |
| 2149 | { |
| 2150 | return false; |
| 2151 | } |
| 2152 | |
| 2153 | // If swapping to a different talisman of the same type, make sure to |
| 2154 | // activate properties of the new one. |
| 2155 | if (using_talisman && you.form == which_trans |
| 2156 | && is_artefact(*you.active_talisman())) |
| 2157 | { |
| 2158 | you.equipment.update(); |
| 2159 | equip_artefact_effect(*you.active_talisman(), nullptr, false); |
| 2160 | |
| 2161 | return true; |
| 2162 | } |
| 2163 | |
| 2164 | // Vampire should shift into bat swarm without reverting to fully untransformed in the middle |
| 2165 | if (you.form != transformation::none |
| 2166 | && !(you.form == transformation::vampire && which_trans == transformation::bat_swarm)) |
| 2167 | { |
| 2168 | untransform(true, !using_talisman, !using_talisman, which_trans); |
| 2169 | } |
| 2170 | |
| 2171 | _enter_form(dur, which_trans, using_talisman); |
| 2172 | |
| 2173 | return true; |
| 2174 | } |
| 2175 | |
| 2176 | /** |
| 2177 | * End the player's transformation and return them to having no |
no test coverage detected