| 1203 | }; |
| 1204 | |
| 1205 | void |
| 1206 | use_crystal_ball(struct obj **optr) |
| 1207 | { |
| 1208 | char ch; |
| 1209 | int oops; |
| 1210 | struct obj *obj = *optr; |
| 1211 | boolean charged = (obj->spe > 0); |
| 1212 | |
| 1213 | if (Blind) { |
| 1214 | pline("Too bad you can't see %s.", the(xname(obj))); |
| 1215 | return; |
| 1216 | } |
| 1217 | oops = is_quest_artifact(obj) ? 8 : obj->blessed ? 16 : 20; |
| 1218 | if (charged && (obj->cursed || rnd(oops) > ACURR(A_INT))) { |
| 1219 | long impair = (long) rnd(100 - 3 * ACURR(A_INT)); |
| 1220 | |
| 1221 | switch (rnd((obj->oartifact || obj->blessed) ? 4 : 5)) { |
| 1222 | case 1: |
| 1223 | pline("%s too much to comprehend!", Tobjnam(obj, "are")); |
| 1224 | break; |
| 1225 | case 2: |
| 1226 | pline("%s you!", Tobjnam(obj, "confuse")); |
| 1227 | make_confused((HConfusion & TIMEOUT) + impair, FALSE); |
| 1228 | break; |
| 1229 | case 3: |
| 1230 | if (!resists_blnd(&gy.youmonst)) { |
| 1231 | pline("%s your vision!", Tobjnam(obj, "damage")); |
| 1232 | make_blinded(BlindedTimeout + impair, FALSE); |
| 1233 | if (!Blind) |
| 1234 | Your1(vision_clears); |
| 1235 | } else { |
| 1236 | pline("%s your vision.", Tobjnam(obj, "assault")); |
| 1237 | You("are unaffected!"); |
| 1238 | } |
| 1239 | break; |
| 1240 | case 4: |
| 1241 | pline("%s your mind!", Tobjnam(obj, "zap")); |
| 1242 | (void) make_hallucinated((HHallucination & TIMEOUT) + impair, |
| 1243 | FALSE, 0L); |
| 1244 | break; |
| 1245 | case 5: |
| 1246 | pline("%s!", Tobjnam(obj, "explode")); |
| 1247 | useup(obj); |
| 1248 | *optr = obj = 0; /* it's gone */ |
| 1249 | /* physical damage cause by the shards and force */ |
| 1250 | losehp(Maybe_Half_Phys(rnd(30)), "exploding crystal ball", |
| 1251 | KILLED_BY_AN); |
| 1252 | break; |
| 1253 | } |
| 1254 | if (obj) |
| 1255 | consume_obj_charge(obj, TRUE); |
| 1256 | return; |
| 1257 | } |
| 1258 | |
| 1259 | if (Hallucination) { |
| 1260 | nomul(-rnd(charged ? 4 : 2)); |
| 1261 | gm.multi_reason = "gazing into a Magic 8-Ball (tm)"; |
| 1262 | gn.nomovemsg = ""; |
no test coverage detected