1 | /* |
1 | /* |
2 | * This file is part of Crossfire TRT, the Roguelike Realtime MORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team |
4 | * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Crossfire TRT is free software: you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation, either version 3 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
… | |
… | |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * |
20 | * |
21 | * The authors can be reached via e-mail to <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | */ |
22 | */ |
23 | |
23 | |
24 | /* |
24 | /* |
25 | * Routines that is executed from objects based on their speed have been |
25 | * Routines that is executed from objects based on their speed have been |
26 | * collected in this file. |
26 | * collected in this file. |
… | |
… | |
34 | * so those will be removed shortly (in a cascade like fashion.) |
34 | * so those will be removed shortly (in a cascade like fashion.) |
35 | */ |
35 | */ |
36 | void |
36 | void |
37 | remove_door (object *op) |
37 | remove_door (object *op) |
38 | { |
38 | { |
39 | int i; |
39 | for (int i = 1; i < SIZEOFFREE1 + 1; i += 2) |
|
|
40 | { |
40 | object *tmp; |
41 | object *tmp; |
41 | |
42 | mapxy pos (op); |
42 | for (i = 1; i < 9; i += 2) |
43 | pos.move (i); |
43 | if ((tmp = present (DOOR, op->map, op->x + freearr_x[i], op->y + freearr_y[i])) != NULL) |
44 | if (pos.normalise () |
|
|
45 | && (tmp = present (DOOR, pos.m, pos.x, pos.y))) |
44 | { |
46 | { |
45 | tmp->set_speed (0.1f); |
47 | tmp->set_speed (0.1f); |
46 | tmp->speed_left = -0.2f; |
48 | tmp->speed_left = -0.2f; |
47 | } |
49 | } |
|
|
50 | } |
48 | |
51 | |
49 | if (op->other_arch) |
52 | if (op->other_arch) |
50 | { |
53 | { |
51 | tmp = arch_to_object (op->other_arch); |
54 | object *tmp = arch_to_object (op->other_arch); |
52 | tmp->x = op->x; |
55 | tmp->x = op->x; |
53 | tmp->y = op->y; |
56 | tmp->y = op->y; |
54 | tmp->map = op->map; |
57 | tmp->map = op->map; |
55 | tmp->level = op->level; |
58 | tmp->level = op->level; |
56 | insert_ob_in_map (tmp, op->map, op, 0); |
59 | insert_ob_in_map (tmp, op->map, op, 0); |
… | |
… | |
297 | } |
300 | } |
298 | else |
301 | else |
299 | { /* The gate is still going up */ |
302 | { /* The gate is still going up */ |
300 | op->stats.wc++; |
303 | op->stats.wc++; |
301 | |
304 | |
302 | if ((int) op->stats.wc >= (NUM_ANIMATIONS (op))) |
305 | if (op->stats.wc >= NUM_ANIMATIONS (op)) |
303 | op->stats.wc = (signed char) NUM_ANIMATIONS (op) - 1; |
306 | op->stats.wc = NUM_ANIMATIONS (op) - 1; |
304 | |
307 | |
305 | /* If there is something on top of the gate, we try to roll it off. |
308 | /* If there is something on top of the gate, we try to roll it off. |
306 | * If a player/monster, we don't roll, we just hit them with damage |
309 | * If a player/monster, we don't roll, we just hit them with damage |
307 | */ |
310 | */ |
308 | if ((int) op->stats.wc >= NUM_ANIMATIONS (op) / 2) |
311 | if (op->stats.wc >= NUM_ANIMATIONS (op) / 2) |
309 | { |
312 | { |
310 | /* Halfway or further, check blocks */ |
313 | /* Halfway or further, check blocks */ |
311 | /* First, get the top object on the square. */ |
314 | /* First, get the top object on the square. */ |
312 | for (tmp = op->above; tmp && tmp->above; tmp = tmp->above) |
315 | for (tmp = op->above; tmp && tmp->above; tmp = tmp->above) |
313 | ; |
316 | ; |
… | |
… | |
327 | * off the gate. |
330 | * off the gate. |
328 | */ |
331 | */ |
329 | else if (!QUERY_FLAG (tmp, FLAG_ALIVE) && (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL))) |
332 | else if (!QUERY_FLAG (tmp, FLAG_ALIVE) && (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL))) |
330 | { |
333 | { |
331 | /* If it has speed, it should move itself, otherwise: */ |
334 | /* If it has speed, it should move itself, otherwise: */ |
332 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
335 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, SIZEOFFREE1 + 1); |
333 | |
336 | |
334 | /* If there is a free spot, move the object someplace */ |
337 | /* If there is a free spot, move the object someplace */ |
335 | if (i != -1) |
338 | if (i > 0) |
336 | { |
339 | { |
|
|
340 | mapxy pos (tmp); |
|
|
341 | pos.move (i); |
|
|
342 | if (pos.normalise ()) |
337 | tmp->remove (); |
343 | tmp->move_to (pos); |
338 | tmp->x += freearr_x[i], tmp->y += freearr_y[i]; |
|
|
339 | insert_ob_in_map (tmp, op->map, op, 0); |
|
|
340 | } |
344 | } |
341 | } |
345 | } |
342 | } |
346 | } |
343 | |
347 | |
344 | /* See if there is still anything blocking the gate */ |
348 | /* See if there is still anything blocking the gate */ |