| 2128 | } |
| 2129 | |
| 2130 | staticfn int |
| 2131 | arti_invoke(struct obj *obj) |
| 2132 | { |
| 2133 | const struct artifact *oart; |
| 2134 | int res = ECMD_OK; |
| 2135 | |
| 2136 | if (!obj) { |
| 2137 | impossible("arti_invoke without obj"); |
| 2138 | return ECMD_OK; |
| 2139 | } |
| 2140 | oart = get_artifact(obj); |
| 2141 | if (oart == &artilist[ART_NONARTIFACT] || !oart->inv_prop) { |
| 2142 | if (obj->otyp == CRYSTAL_BALL) |
| 2143 | use_crystal_ball(&obj); |
| 2144 | else |
| 2145 | pline1(nothing_happens); |
| 2146 | return ECMD_TIME; |
| 2147 | } |
| 2148 | |
| 2149 | /* It's a special power, not "just" a property */ |
| 2150 | if (oart->inv_prop > LAST_PROP) { |
| 2151 | if (!arti_invoke_cost(obj)) |
| 2152 | return ECMD_TIME; |
| 2153 | |
| 2154 | switch (oart->inv_prop) { |
| 2155 | case TAMING: res = invoke_taming(obj); break; |
| 2156 | case HEALING: res = invoke_healing(obj); break; |
| 2157 | case ENERGY_BOOST: res = invoke_energy_boost(obj); break; |
| 2158 | case UNTRAP: res = invoke_untrap(obj); break; |
| 2159 | case CHARGE_OBJ: res = invoke_charge_obj(obj); break; |
| 2160 | case LEV_TELE: level_tele(); res = ECMD_TIME; break; |
| 2161 | case CREATE_PORTAL: res = invoke_create_portal(obj); break; |
| 2162 | case ENLIGHTENING: |
| 2163 | enlightenment(MAGICENLIGHTENMENT, ENL_GAMEINPROGRESS); |
| 2164 | res = ECMD_TIME; |
| 2165 | break; |
| 2166 | case CREATE_AMMO: res = invoke_create_ammo(obj); break; |
| 2167 | case BANISH: res = invoke_banish(obj); break; |
| 2168 | case FLING_POISON: res = invoke_fling_poison(obj); break; |
| 2169 | case SNOWSTORM: |
| 2170 | /*FALLTHRU*/ |
| 2171 | case FIRESTORM: res = invoke_storm_spell(obj); break; |
| 2172 | case BLINDING_RAY: res = invoke_blinding_ray(obj); break; |
| 2173 | default: |
| 2174 | impossible("Unknown invoke power %d.", oart->inv_prop); |
| 2175 | break; |
| 2176 | } |
| 2177 | return res; |
| 2178 | } else { |
| 2179 | long eprop = (u.uprops[oart->inv_prop].extrinsic ^= W_ARTI), |
| 2180 | iprop = u.uprops[oart->inv_prop].intrinsic; |
| 2181 | boolean on = (eprop & W_ARTI) != 0; /* true if prop just set */ |
| 2182 | |
| 2183 | if (on && obj->age > svm.moves) { |
| 2184 | /* the artifact is tired :-) */ |
| 2185 | u.uprops[oart->inv_prop].extrinsic ^= W_ARTI; |
| 2186 | You_feel("that %s %s ignoring you.", the(xname(obj)), |
| 2187 | otense(obj, "are")); |
no test coverage detected