1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
|
|
4 | * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
8 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
12 | * option) any later version. |
12 | * |
13 | * |
13 | * This program is distributed in the hope that it will be useful, |
14 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
17 | * GNU General Public License for more details. |
17 | * |
18 | * |
18 | * You should have received a copy of the Affero GNU General Public License |
19 | * You should have received a copy of the Affero GNU General Public License |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
21 | * <http://www.gnu.org/licenses/>. |
21 | * |
22 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
24 | */ |
24 | |
25 | |
25 | #include <global.h> |
26 | #include <global.h> |
26 | #ifndef __CEXTRACT__ |
27 | #ifndef __CEXTRACT__ |
… | |
… | |
28 | #endif |
29 | #endif |
29 | |
30 | |
30 | int |
31 | int |
31 | object::move (int dir, object *originator) |
32 | object::move (int dir, object *originator) |
32 | { |
33 | { |
33 | sint16 newx = x + freearr_x[dir]; |
34 | sint16 newx = x + DIRX (dir); |
34 | sint16 newy = y + freearr_y[dir]; |
35 | sint16 newy = y + DIRY (dir); |
35 | |
36 | |
36 | mapxy pos (this); |
37 | mapxy pos (this); |
37 | pos.move (dir); |
38 | pos.move (dir); |
38 | |
39 | |
39 | /* If the space the object is moving to is out of the map, |
40 | /* If the space the object is moving to is out of the map, |
… | |
… | |
120 | op = op->head_ (); |
121 | op = op->head_ (); |
121 | op->remove (); |
122 | op->remove (); |
122 | |
123 | |
123 | for (object *tmp = op; tmp; tmp = tmp->more) |
124 | for (object *tmp = op; tmp; tmp = tmp->more) |
124 | { |
125 | { |
125 | tmp->x = x + freearr_x[i] + tmp->arch->x; |
126 | tmp->x = x + DIRX (i) + tmp->arch->x; |
126 | tmp->y = y + freearr_y[i] + tmp->arch->y; |
127 | tmp->y = y + DIRY (i) + tmp->arch->y; |
127 | } |
128 | } |
128 | |
129 | |
129 | op = insert_ob_in_map (op, op->map, originator, 0); |
130 | op = insert_ob_in_map (op, op->map, originator, 0); |
130 | |
131 | |
131 | return !op; |
132 | return !op; |
… | |
… | |
196 | { |
197 | { |
197 | maptile *m; |
198 | maptile *m; |
198 | sint16 sx, sy; |
199 | sint16 sx, sy; |
199 | |
200 | |
200 | if (get_map_flags (other_teleporter->map, &m, |
201 | if (get_map_flags (other_teleporter->map, &m, |
201 | other_teleporter->x + freearr_x[k], other_teleporter->y + freearr_y[k], &sx, &sy) & P_OUT_OF_MAP) |
202 | other_teleporter->x + DIRX (k), other_teleporter->y + DIRY (k), &sx, &sy) & P_OUT_OF_MAP) |
202 | continue; |
203 | continue; |
203 | |
204 | |
204 | if (!OB_TYPE_MOVE_BLOCK (user, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
205 | if (!OB_TYPE_MOVE_BLOCK (user, GET_MAP_MOVE_BLOCK (m, sx, sy))) |
205 | break; |
206 | break; |
206 | } |
207 | } |
… | |
… | |
215 | else |
216 | else |
216 | return 0; |
217 | return 0; |
217 | } |
218 | } |
218 | |
219 | |
219 | return !other_teleporter->map->insert ( |
220 | return !other_teleporter->map->insert ( |
220 | user, other_teleporter->x + freearr_x[k], other_teleporter->y + freearr_y[k] |
221 | user, other_teleporter->x + DIRX (k), other_teleporter->y + DIRY (k) |
221 | ); |
222 | ); |
222 | } |
223 | } |
223 | |
224 | |
224 | /* |
225 | /* |
225 | * This is a new version of blocked, this one handles objects |
226 | * This is a new version of blocked, this one handles objects |
… | |
… | |
265 | } |
266 | } |
266 | return 0; |
267 | return 0; |
267 | } |
268 | } |
268 | |
269 | |
269 | /* |
270 | /* |
270 | * this is not perfect yet. |
271 | * this is not perfect yet. |
271 | * it does not roll objects behind multipart objects properly. |
272 | * it does not roll objects behind multipart objects properly. |
272 | * Support for rolling multipart objects is questionable. |
273 | * Support for rolling multipart objects is questionable. |
273 | */ |
274 | */ |
274 | static int |
275 | static int |
275 | roll_ob (object *op, int dir, object *pusher) |
276 | roll_ob (object *op, int dir, object *pusher) |
… | |
… | |
280 | MoveType move_block; |
281 | MoveType move_block; |
281 | |
282 | |
282 | if (op->head) |
283 | if (op->head) |
283 | op = op->head; |
284 | op = op->head; |
284 | |
285 | |
285 | x = op->x + freearr_x[dir]; |
286 | x = op->x + DIRX (dir); |
286 | y = op->y + freearr_y[dir]; |
287 | y = op->y + DIRY (dir); |
287 | |
288 | |
288 | if (!op->flag [FLAG_CAN_ROLL] |
289 | if (!op->flag [FLAG_CAN_ROLL] |
289 | || (op->weight && random_roll (0, op->weight / 50000 - 1, pusher, PREFER_LOW) |
290 | || (op->weight && random_roll (0, op->weight / 50000 - 1, pusher, PREFER_LOW) |
290 | > pusher->stats.Str)) |
291 | > pusher->stats.Str)) |
291 | return 0; |
292 | return 0; |