| 2052 | } |
| 2053 | |
| 2054 | staticfn void |
| 2055 | seffect_identify(struct obj **sobjp) |
| 2056 | { |
| 2057 | struct obj *sobj = *sobjp; |
| 2058 | int otyp = sobj->otyp; |
| 2059 | boolean is_scroll = (sobj->oclass == SCROLL_CLASS); |
| 2060 | boolean sblessed = sobj->blessed; |
| 2061 | boolean scursed = sobj->cursed; |
| 2062 | boolean confused = (Confusion != 0); |
| 2063 | boolean already_known = (sobj->oclass == SPBOOK_CLASS /* spell */ |
| 2064 | || objects[otyp].oc_name_known); |
| 2065 | |
| 2066 | if (is_scroll) { /* scroll of identify */ |
| 2067 | /* known = TRUE; -- handled inline here */ |
| 2068 | /* use up the scroll first, before learnscrolltyp() -> makeknown() |
| 2069 | performs perm_invent update; also simplifies empty invent check */ |
| 2070 | useup(sobj); |
| 2071 | *sobjp = 0; /* it's gone */ |
| 2072 | /* scroll just identifies itself for any scroll read while confused |
| 2073 | or for cursed scroll read without knowing identify yet */ |
| 2074 | if (confused || (scursed && !already_known)) |
| 2075 | You("identify this as an identify scroll."); |
| 2076 | else if (!already_known) |
| 2077 | pline("This is an identify scroll."); |
| 2078 | if (!already_known) |
| 2079 | (void) learnscrolltyp(SCR_IDENTIFY); |
| 2080 | if (confused || (scursed && !already_known)) |
| 2081 | return; |
| 2082 | } |
| 2083 | |
| 2084 | if (gi.invent) { |
| 2085 | int cval = 1; |
| 2086 | if (sblessed || (!scursed && !rn2(5))) { |
| 2087 | cval = rn2(5); |
| 2088 | /* note: if cval==0, identify all items */ |
| 2089 | if (cval == 1 && sblessed && Luck > 0) |
| 2090 | ++cval; |
| 2091 | } |
| 2092 | identify_pack(cval, !already_known); |
| 2093 | } else { |
| 2094 | /* spell cast with inventory empty or scroll read when it's |
| 2095 | the only item leaving empty inventory after being used up */ |
| 2096 | pline("You're not carrying anything%s to be identified.", |
| 2097 | (is_scroll) ? " else" : ""); |
| 2098 | } |
| 2099 | } |
| 2100 | |
| 2101 | staticfn void |
| 2102 | seffect_magic_mapping(struct obj **sobjp) |
no test coverage detected