* Casting-specific checks that are involved when casting any spell or larger * groups of spells (e.g. entire schools). Includes MP (which does use the * spell level if provided), confusion state, banned schools. * * @param spell The spell in question. * @param temp Include checks for volatile or temporary states * (status effects, mana) # @return A rea
| 1190 | # @return A reason why casting is useless, or "" if it isn't. |
| 1191 | */ |
| 1192 | string casting_uselessness_reason(spell_type spell, bool temp) |
| 1193 | { |
| 1194 | if (temp) |
| 1195 | { |
| 1196 | if (you.duration[DUR_CONF] > 0) |
| 1197 | return "you're too confused to cast spells."; |
| 1198 | |
| 1199 | if (spell_difficulty(spell) > you.experience_level) |
| 1200 | return "you aren't experienced enough to cast this spell."; |
| 1201 | |
| 1202 | if (you.has_mutation(MUT_HP_CASTING)) |
| 1203 | { |
| 1204 | // TODO: deduplicate with enough_hp() |
| 1205 | if (you.duration[DUR_DEATHS_DOOR]) |
| 1206 | return "you cannot pay life while functionally dead."; |
| 1207 | if (!enough_hp(spell_mana(spell), true, false)) |
| 1208 | return "you don't have enough health to cast this spell."; |
| 1209 | } |
| 1210 | else if (!enough_mp(spell_mana(spell), true, false)) |
| 1211 | return "you don't have enough magic to cast this spell."; |
| 1212 | |
| 1213 | if (spell == SPELL_SUBLIMATION_OF_BLOOD |
| 1214 | && you.magic_points == you.max_magic_points) |
| 1215 | { |
| 1216 | if (you.has_mutation(MUT_HP_CASTING)) |
| 1217 | return "your magic and health are inextricable."; |
| 1218 | return "your reserves of magic are already full."; |
| 1219 | } |
| 1220 | |
| 1221 | if (you.form == transformation::walking_scroll && spell_difficulty(spell) > 4) |
| 1222 | return "you cannot cast such powerful magic in your current form."; |
| 1223 | } |
| 1224 | |
| 1225 | // Check for banned schools (Currently just Ru sacrifices) |
| 1226 | if (cannot_use_schools(get_spell_disciplines(spell))) |
| 1227 | return "you cannot use spells of this school."; |
| 1228 | |
| 1229 | // TODO: these checks were in separate places, but is this already covered |
| 1230 | // by cannot_use_schools? |
| 1231 | if (get_spell_disciplines(spell) & spschool::summoning |
| 1232 | && you.allies_forbidden()) |
| 1233 | { |
| 1234 | return "you cannot coerce anything to answer your summons."; |
| 1235 | } |
| 1236 | |
| 1237 | // other ally spells not affected by the school checks |
| 1238 | switch (spell) |
| 1239 | { |
| 1240 | case SPELL_ANIMATE_DEAD: |
| 1241 | case SPELL_DEATH_CHANNEL: |
| 1242 | case SPELL_SIMULACRUM: |
| 1243 | case SPELL_INFESTATION: |
| 1244 | case SPELL_TUKIMAS_DANCE: |
| 1245 | case SPELL_HOARFROST_CANNONADE: |
| 1246 | case SPELL_SOUL_SPLINTER: |
| 1247 | case SPELL_CLOCKWORK_BEE: |
| 1248 | case SPELL_PLATINUM_PARAGON: |
| 1249 | case SPELL_WALKING_ALEMBIC: |
no test coverage detected