increment a combat intrinsic with limits on its growth */
| 2218 | |
| 2219 | /* increment a combat intrinsic with limits on its growth */ |
| 2220 | staticfn int |
| 2221 | bounded_increase(int old, int inc, int typ) |
| 2222 | { |
| 2223 | int absold, absinc, sgnold, sgninc; |
| 2224 | |
| 2225 | /* don't include any amount coming from worn rings (caller handles |
| 2226 | 'protection' differently) */ |
| 2227 | if (uright && uright->otyp == typ && typ != RIN_PROTECTION) |
| 2228 | old -= uright->spe; |
| 2229 | if (uleft && uleft->otyp == typ && typ != RIN_PROTECTION) |
| 2230 | old -= uleft->spe; |
| 2231 | absold = abs(old), absinc = abs(inc); |
| 2232 | sgnold = sgn(old), sgninc = sgn(inc); |
| 2233 | |
| 2234 | if (absinc == 0 || sgnold != sgninc || absold + absinc < 10) { |
| 2235 | ; /* use inc as-is */ |
| 2236 | } else if (absold + absinc < 20) { |
| 2237 | absinc = rnd(absinc); /* 1..n */ |
| 2238 | if (absold + absinc < 10) |
| 2239 | absinc = 10 - absold; |
| 2240 | inc = sgninc * absinc; |
| 2241 | } else if (absold + absinc < 40) { |
| 2242 | absinc = rn2(absinc) ? 1 : 0; |
| 2243 | if (absold + absinc < 20) |
| 2244 | absinc = rnd(20 - absold); |
| 2245 | inc = sgninc * absinc; |
| 2246 | } else { |
| 2247 | inc = 0; /* no further increase allowed via this method */ |
| 2248 | } |
| 2249 | /* put amount from worn rings back */ |
| 2250 | if (uright && uright->otyp == typ && typ != RIN_PROTECTION) |
| 2251 | old += uright->spe; |
| 2252 | if (uleft && uleft->otyp == typ && typ != RIN_PROTECTION) |
| 2253 | old += uleft->spe; |
| 2254 | return old + inc; |
| 2255 | } |
| 2256 | |
| 2257 | staticfn void |
| 2258 | accessory_has_effect(struct obj *otmp) |
no test coverage detected