MCPcopy Create free account
hub / github.com/NetHack/NetHack / Amulet_on

Function Amulet_on

src/do_wear.c:962–1087  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

960}
961
962staticfn void
963Amulet_on(struct obj *amul)
964{
965 boolean on_msg_done = FALSE;
966
967 /* make sure amulet isn't wielded/alt-wielded/quivered, before wearing */
968 remove_worn_item(amul, FALSE);
969 setworn(amul, W_AMUL);
970
971 switch (uamul->otyp) {
972 case AMULET_OF_ESP:
973 case AMULET_OF_LIFE_SAVING:
974 case AMULET_VERSUS_POISON:
975 case AMULET_OF_REFLECTION:
976 case FAKE_AMULET_OF_YENDOR:
977 break;
978 case AMULET_OF_MAGICAL_BREATHING: {
979 boolean was_in_poison_gas;
980
981 /* amulet is already on; we need to check hero's gas-cloud status
982 when it was off */
983 EMagical_breathing &= ~W_AMUL;
984 was_in_poison_gas = region_danger();
985 EMagical_breathing |= W_AMUL;
986 if (was_in_poison_gas) {
987 makeknown(AMULET_OF_MAGICAL_BREATHING);
988 on_msg(uamul);
989 on_msg_done = TRUE;
990 You("are no longer bothered by the poison gas.");
991 }
992 /* no need to check for becoming able to breathe underwater;
993 if we are underwater, we already can or we would have drowned */
994 break;
995 }
996 case AMULET_OF_UNCHANGING:
997 if (Slimed)
998 make_slimed(0L, (char *) 0);
999 break;
1000 case AMULET_OF_CHANGE: {
1001 boolean call_it = FALSE;
1002 int new_sex, orig_sex = poly_gender();
1003
1004 /* in normal play it's not possible to put on an amulet of change
1005 while already wearing an amulet of unchanging, but in wizard
1006 mode the Unchanging attribute can be set via #wizintrinsic */
1007 if (!Unchanging)
1008 change_sex();
1009
1010 new_sex = poly_gender();
1011 if (new_sex != orig_sex)
1012 makeknown(AMULET_OF_CHANGE);
1013 on_msg(uamul); /* show 'z - amulet of change (being worn)' */
1014 on_msg_done = TRUE;
1015
1016 /* Don't use same message as polymorph */
1017 if (new_sex != orig_sex) {
1018 newsym(u.ux, u.uy); /* glyphmon flag and tile have changed */
1019 disp.botl = TRUE; /* role name or rank title might have changed */

Callers 2

set_wearFunction · 0.85
accessory_or_armor_onFunction · 0.85

Calls 15

remove_worn_itemFunction · 0.85
setwornFunction · 0.85
region_dangerFunction · 0.85
on_msgFunction · 0.85
YouFunction · 0.85
make_slimedFunction · 0.85
poly_genderFunction · 0.85
change_sexFunction · 0.85
newsymFunction · 0.85
livelog_newformFunction · 0.85
pline_TheFunction · 0.85
trycallFunction · 0.85

Tested by

no test coverage detected