… | |
… | |
2210 | new_aura->set_owner (op); |
2210 | new_aura->set_owner (op); |
2211 | |
2211 | |
2212 | return 1; |
2212 | return 1; |
2213 | } |
2213 | } |
2214 | |
2214 | |
2215 | |
|
|
2216 | /* move aura function. An aura is a part of someone's inventory, |
2215 | /* move aura function. An aura is a part of someone's inventory, |
2217 | * which he carries with him, but which acts on the map immediately |
2216 | * which he carries with him, but which acts on the map immediately |
2218 | * around him. |
2217 | * around him. |
2219 | * Aura parameters: |
2218 | * Aura parameters: |
2220 | * duration: duration counter. |
2219 | * duration: duration counter. |
2221 | * attacktype: aura's attacktype |
2220 | * attacktype: aura's attacktype |
2222 | * other_arch: archetype to drop where we attack |
2221 | * other_arch: archetype to drop where we attack |
2223 | */ |
2222 | */ |
2224 | |
|
|
2225 | void |
2223 | void |
2226 | move_aura (object *aura) |
2224 | move_aura (object *aura) |
2227 | { |
2225 | { |
2228 | int i, mflags; |
|
|
2229 | object *env; |
|
|
2230 | maptile *m; |
|
|
2231 | |
|
|
2232 | /* auras belong in inventories */ |
2226 | /* auras belong in inventories */ |
2233 | env = aura->env; |
2227 | object *env = aura->env; |
|
|
2228 | object *owner = aura->owner; |
2234 | |
2229 | |
2235 | /* no matter what we've gotta remove the aura... |
2230 | /* no matter what we've gotta remove the aura... |
2236 | * we'll put it back if its time isn't up. |
2231 | * we'll put it back if its time isn't up. |
2237 | */ |
2232 | */ |
2238 | aura->remove (); |
2233 | aura->remove (); |
… | |
… | |
2243 | aura->destroy (); |
2238 | aura->destroy (); |
2244 | return; |
2239 | return; |
2245 | } |
2240 | } |
2246 | |
2241 | |
2247 | /* auras only exist in inventories */ |
2242 | /* auras only exist in inventories */ |
2248 | if (env == NULL || env->map == NULL) |
2243 | if (!env || !env->map) |
2249 | { |
2244 | { |
2250 | aura->destroy (); |
2245 | aura->destroy (); |
2251 | return; |
2246 | return; |
2252 | } |
2247 | } |
2253 | |
2248 | |
2254 | /* we need to jump out of the inventory for a bit |
2249 | /* we need to jump out of the inventory for a bit |
2255 | * in order to hit the map conveniently. |
2250 | * in order to hit the map conveniently. |
2256 | */ |
2251 | */ |
2257 | aura->insert_at (env, aura); |
2252 | aura->insert_at (env, aura); |
2258 | |
2253 | |
2259 | for (i = 1; i < 9; i++) |
2254 | for (int i = 1; i < 9; i++) |
2260 | { |
2255 | { |
2261 | sint16 nx, ny; |
2256 | mapxy pos (env); |
|
|
2257 | pos.move (i); |
2262 | |
2258 | |
2263 | nx = aura->x + freearr_x[i]; |
|
|
2264 | ny = aura->y + freearr_y[i]; |
|
|
2265 | mflags = get_map_flags (env->map, &m, nx, ny, &nx, &ny); |
|
|
2266 | |
|
|
2267 | /* Consider the movement tyep of the person with the aura as |
2259 | /* Consider the movement type of the person with the aura as |
2268 | * movement type of the aura. Eg, if the player is flying, the aura |
2260 | * movement type of the aura. Eg, if the player is flying, the aura |
2269 | * is flying also, if player is walking, it is on the ground, etc. |
2261 | * is flying also, if player is walking, it is on the ground, etc. |
2270 | */ |
2262 | */ |
2271 | if (!(mflags & P_OUT_OF_MAP) && !(OB_TYPE_MOVE_BLOCK (env, GET_MAP_MOVE_BLOCK (m, nx, ny)))) |
2263 | if (pos.normalise () && !(OB_TYPE_MOVE_BLOCK (env, pos->move_block))) |
2272 | { |
2264 | { |
2273 | hit_map (aura, i, aura->attacktype, 0); |
2265 | hit_map (aura, i, aura->attacktype, 0); |
2274 | |
2266 | |
2275 | if (aura->other_arch) |
2267 | if (aura->other_arch) |
2276 | m->insert (arch_to_object (aura->other_arch), nx, ny, aura); |
2268 | pos.insert (arch_to_object (aura->other_arch), aura); |
2277 | } |
2269 | } |
2278 | } |
2270 | } |
2279 | |
2271 | |
2280 | /* put the aura back in the player's inventory */ |
2272 | /* put the aura back in the player's inventory */ |
2281 | aura->remove (); |
2273 | env->insert (aura); |
2282 | insert_ob_in_ob (aura, env); |
2274 | aura->set_owner (owner); |
2283 | } |
2275 | } |
2284 | |
2276 | |
2285 | /* moves the peacemaker spell. |
2277 | /* moves the peacemaker spell. |
2286 | * op is the piece object. |
2278 | * op is the piece object. |
2287 | */ |
2279 | */ |