| 1217 | } |
| 1218 | |
| 1219 | staticfn boolean |
| 1220 | spelleffects_check(int spell, int *res, int *energy) |
| 1221 | { |
| 1222 | int chance; |
| 1223 | boolean confused = (Confusion != 0); |
| 1224 | |
| 1225 | *energy = 0; |
| 1226 | |
| 1227 | /* |
| 1228 | * Reject attempting to cast while stunned or with no free hands. |
| 1229 | * Already done in getspell() to stop casting before choosing |
| 1230 | * which spell, but duplicated here for cases where spelleffects() |
| 1231 | * gets called directly for ^T without intrinsic teleport capability |
| 1232 | * or #turn for non-priest/non-knight. |
| 1233 | * (There's no duplication of messages; when the rejection takes |
| 1234 | * place in getspell(), we don't get called.) |
| 1235 | */ |
| 1236 | if ((spell == UNKNOWN_SPELL) || rejectcasting()) { |
| 1237 | *res = ECMD_OK; /* no time elapses */ |
| 1238 | return TRUE; |
| 1239 | } |
| 1240 | |
| 1241 | /* |
| 1242 | * Note: dotele() also calculates energy use and checks nutrition |
| 1243 | * and strength requirements; if any of these change, update it too. |
| 1244 | */ |
| 1245 | *energy = SPELL_LEV_PW(spellev(spell)); /* 5 <= energy <= 35 */ |
| 1246 | |
| 1247 | /* |
| 1248 | * Spell casting no longer affects knowledge of the spell. A |
| 1249 | * decrement of spell knowledge is done every turn. |
| 1250 | */ |
| 1251 | if (spellknow(spell) <= 0) { |
| 1252 | Your("knowledge of this spell is twisted."); |
| 1253 | pline("It invokes nightmarish images in your mind..."); |
| 1254 | spell_backfire(spell); |
| 1255 | u.uen -= rnd(*energy); |
| 1256 | if (u.uen < 0) |
| 1257 | u.uen = 0; |
| 1258 | disp.botl = TRUE; |
| 1259 | *res = ECMD_TIME; |
| 1260 | return TRUE; |
| 1261 | } else if (spellknow(spell) <= KEEN / 200) { /* 100 turns left */ |
| 1262 | You("strain to recall the spell."); |
| 1263 | } else if (spellknow(spell) <= KEEN / 40) { /* 500 turns left */ |
| 1264 | You("have difficulty remembering the spell."); |
| 1265 | } else if (spellknow(spell) <= KEEN / 20) { /* 1000 turns left */ |
| 1266 | Your("knowledge of this spell is growing faint."); |
| 1267 | } else if (spellknow(spell) <= KEEN / 10) { /* 2000 turns left */ |
| 1268 | Your("recall of this spell is gradually fading."); |
| 1269 | } |
| 1270 | |
| 1271 | if (u.uhunger <= 10 && spellid(spell) != SPE_DETECT_FOOD) { |
| 1272 | You("are too hungry to cast that spell."); |
| 1273 | *res = ECMD_OK; |
| 1274 | return TRUE; |
| 1275 | } else if (ACURR(A_STR) < 4 && spellid(spell) != SPE_RESTORE_ABILITY) { |
| 1276 | You("lack the strength to cast spells."); |
no test coverage detected