MCPcopy Index your code
hub / github.com/NetHack/NetHack / chwepon

Function chwepon

src/wield.c:917–1048  ·  view source on GitHub ↗

enchant wielded weapon */

Source from the content-addressed store, hash-verified

915
916/* enchant wielded weapon */
917int
918chwepon(struct obj *otmp, int amount)
919{
920 const char *color = hcolor((amount < 0) ? NH_BLACK : NH_BLUE);
921 const char *xtime, *wepname = "";
922 boolean multiple;
923 int otyp = STRANGE_OBJECT;
924
925 if (!uwep || (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep))) {
926 char buf[BUFSZ];
927
928 if (amount >= 0 && uwep && will_weld(uwep)) { /* cursed tin opener */
929 if (!Blind) {
930 Sprintf(buf, "%s with %s aura.",
931 Yobjnam2(uwep, "glow"), an(hcolor(NH_AMBER)));
932 uwep->bknown = !Hallucination; /* ok to bypass set_bknown() */
933 } else {
934 /* cursed tin opener is wielded in right hand */
935 Sprintf(buf, "Your right %s tingles.", body_part(HAND));
936 }
937 uncurse(uwep);
938 update_inventory();
939 } else {
940 Sprintf(buf, "Your %s %s.", makeplural(body_part(HAND)),
941 (amount >= 0) ? "twitch" : "itch");
942 }
943 strange_feeling(otmp, buf); /* pline()+docall()+useup() */
944 exercise(A_DEX, (boolean) (amount >= 0));
945 return 0;
946 }
947
948 if (otmp && otmp->oclass == SCROLL_CLASS)
949 otyp = otmp->otyp;
950
951 if (uwep->otyp == WORM_TOOTH && amount >= 0) {
952 multiple = (uwep->quan > 1L);
953 /* order: message, transformation, shop handling */
954 Your("%s %s much sharper now.", simpleonames(uwep),
955 multiple ? "fuse, and become" : "is");
956 uwep->otyp = CRYSKNIFE;
957 uwep->oerodeproof = 0;
958 if (multiple) {
959 uwep->quan = 1L;
960 uwep->owt = weight(uwep);
961 }
962 if (uwep->cursed)
963 uncurse(uwep);
964 /* update shop bill to reflect new higher value */
965 if (uwep->unpaid)
966 alter_cost(uwep, 0L);
967 if (otyp != STRANGE_OBJECT)
968 makeknown(otyp);
969 if (multiple)
970 encumber_msg();
971 return 1;
972 } else if (uwep->otyp == CRYSKNIFE && amount < 0) {
973 multiple = (uwep->quan > 1L);
974 /* order matters: message, shop handling, transformation */

Callers 1

seffect_enchant_weaponFunction · 0.85

Calls 15

hcolorFunction · 0.85
Yobjnam2Function · 0.85
anFunction · 0.85
body_partFunction · 0.85
uncurseFunction · 0.85
update_inventoryFunction · 0.85
makepluralFunction · 0.85
strange_feelingFunction · 0.85
exerciseFunction · 0.85
YourFunction · 0.85
simpleonamesFunction · 0.85
weightFunction · 0.85

Tested by

no test coverage detected