change hero's alignment type, possibly losing use of artifacts */
| 1317 | |
| 1318 | /* change hero's alignment type, possibly losing use of artifacts */ |
| 1319 | void |
| 1320 | uchangealign( |
| 1321 | int newalign, |
| 1322 | int reason) /* A_CG_CONVERT, A_CG_HELM_ON, or A_CG_HELM_OFF */ |
| 1323 | { |
| 1324 | aligntyp oldalign = u.ualign.type; |
| 1325 | |
| 1326 | u.ublessed = 0; /* lose divine protection */ |
| 1327 | /* You/Your/pline message with call flush_screen(), triggering bot(), |
| 1328 | so the actual data change needs to come before the message */ |
| 1329 | disp.botl = TRUE; /* status line needs updating */ |
| 1330 | if (reason == A_CG_CONVERT) { |
| 1331 | /* conversion via altar */ |
| 1332 | livelog_printf(LL_ALIGNMENT, "permanently converted to %s", |
| 1333 | aligns[1 - newalign].adj); |
| 1334 | u.ualignbase[A_CURRENT] = (aligntyp) newalign; |
| 1335 | /* worn helm of opposite alignment might block change */ |
| 1336 | if (!uarmh || uarmh->otyp != HELM_OF_OPPOSITE_ALIGNMENT) |
| 1337 | u.ualign.type = u.ualignbase[A_CURRENT]; |
| 1338 | You("have a %ssense of a new direction.", |
| 1339 | (u.ualign.type != oldalign) ? "sudden " : ""); |
| 1340 | } else { |
| 1341 | /* putting on or taking off a helm of opposite alignment */ |
| 1342 | u.ualign.type = (aligntyp) newalign; |
| 1343 | if (reason == A_CG_HELM_ON) { |
| 1344 | adjalign(-7); /* for abuse -- record will be cleared shortly */ |
| 1345 | Your("mind oscillates %s.", Hallucination ? "wildly" : "briefly"); |
| 1346 | make_confused(rn1(2, 3), FALSE); |
| 1347 | if (Is_astralevel(&u.uz) || ((unsigned) rn2(50) < u.ualign.abuse)) |
| 1348 | summon_furies(Is_astralevel(&u.uz) ? 0 : 1); |
| 1349 | /* don't livelog taking it back off */ |
| 1350 | livelog_printf(LL_ALIGNMENT, "used a helm to turn %s", |
| 1351 | aligns[1 - newalign].adj); |
| 1352 | } else if (reason == A_CG_HELM_OFF) { |
| 1353 | Your("mind is %s.", Hallucination |
| 1354 | ? "much of a muchness" |
| 1355 | : "back in sync with your body"); |
| 1356 | } |
| 1357 | } |
| 1358 | if (u.ualign.type != oldalign) { |
| 1359 | u.ualign.record = 0; /* slate is wiped clean */ |
| 1360 | retouch_equipment(0); |
| 1361 | } |
| 1362 | } |
| 1363 | |
| 1364 | /*attrib.c*/ |
no test coverage detected