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 (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * 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 |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * 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 |
9 | * 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 |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * 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, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
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 Affero GNU General Public License |
18 | * 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 |
19 | * and the GNU General Public License along with this program. If not, see |
20 | * <http://www.gnu.org/licenses/>. |
20 | * <http://www.gnu.org/licenses/>. |
21 | * |
21 | * |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
22 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <global.h> |
25 | #include <global.h> |
26 | #ifndef __CEXTRACT__ |
26 | #ifndef __CEXTRACT__ |
… | |
… | |
75 | if (INVOKE_MAP (LEAVE, map, ARG_PLAYER (contr))) |
75 | if (INVOKE_MAP (LEAVE, map, ARG_PLAYER (contr))) |
76 | return 0; |
76 | return 0; |
77 | |
77 | |
78 | remove (); |
78 | remove (); |
79 | |
79 | |
|
|
80 | pos.m->activate (); |
|
|
81 | |
80 | if (INVOKE_PLAYER (MAP_CHANGE, contr, ARG_MAP (pos.m), ARG_INT (pos.x), ARG_INT (pos.y))) |
82 | if (INVOKE_PLAYER (MAP_CHANGE, contr, ARG_MAP (pos.m), ARG_INT (pos.x), ARG_INT (pos.y))) |
81 | return 0; |
83 | return 0; |
82 | |
84 | |
83 | if (INVOKE_MAP (ENTER, pos.m, ARG_PLAYER (contr), ARG_INT (pos.x), ARG_INT (pos.y))) |
85 | if (INVOKE_MAP (ENTER, pos.m, ARG_PLAYER (contr), ARG_INT (pos.x), ARG_INT (pos.y))) |
84 | return 0; |
86 | return 0; |
… | |
… | |
104 | |
106 | |
105 | int |
107 | int |
106 | transfer_ob (object *op, int x, int y, int randomly, object *originator) |
108 | transfer_ob (object *op, int x, int y, int randomly, object *originator) |
107 | { |
109 | { |
108 | int i; |
110 | int i; |
109 | object *tmp; |
|
|
110 | |
111 | |
111 | if (randomly) |
112 | if (randomly) |
112 | i = find_free_spot (op, op->map, x, y, 0, SIZEOFFREE); |
113 | i = find_free_spot (op, op->map, x, y, 0, SIZEOFFREE); |
113 | else |
114 | else |
114 | i = find_first_free_spot (op, op->map, x, y); |
115 | i = find_first_free_spot (op, op->map, x, y); |
… | |
… | |
176 | LOG (llevError, "%s: no alternative teleporters around (user %s).\n", |
177 | LOG (llevError, "%s: no alternative teleporters around (user %s).\n", |
177 | teleporter->debug_desc (), user->debug_desc ()); |
178 | teleporter->debug_desc (), user->debug_desc ()); |
178 | return 0; |
179 | return 0; |
179 | } |
180 | } |
180 | |
181 | |
181 | int k = find_free_spot (user, other_teleporter->map, other_teleporter->x, other_teleporter->y, 1, 9); |
182 | int k = find_free_spot (user, other_teleporter->map, other_teleporter->x, other_teleporter->y, 1, SIZEOFFREE1 + 1); |
182 | |
183 | |
183 | /* if k==-1, unable to find a free spot. If this is shop |
184 | /* if k==-1, unable to find a free spot. If this is shop |
184 | * mat that the player is using, find someplace to move |
185 | * mat that the player is using, find someplace to move |
185 | * the player - otherwise, player can get trapped in the shops |
186 | * the player - otherwise, player can get trapped in the shops |
186 | * that appear in random dungeons. We basically just make |
187 | * that appear in random dungeons. We basically just make |
… | |
… | |
252 | for (tmp = GET_MAP_OB (m2, tx, ty); tmp; tmp = tmp->above) |
253 | for (tmp = GET_MAP_OB (m2, tx, ty); tmp; tmp = tmp->above) |
253 | { |
254 | { |
254 | if (tmp->head == op || tmp == op) |
255 | if (tmp->head == op || tmp == op) |
255 | continue; |
256 | continue; |
256 | |
257 | |
257 | if ((QUERY_FLAG (tmp, FLAG_ALIVE) && tmp->type != DOOR)) |
258 | if ((tmp->flag [FLAG_ALIVE] && tmp->type != DOOR)) |
258 | return 1; |
259 | return 1; |
259 | |
260 | |
260 | if (OB_MOVE_BLOCK (op, tmp)) |
261 | if (OB_MOVE_BLOCK (op, tmp)) |
261 | return 1; |
262 | return 1; |
262 | |
263 | |
… | |
… | |
282 | op = op->head; |
283 | op = op->head; |
283 | |
284 | |
284 | x = op->x + freearr_x[dir]; |
285 | x = op->x + freearr_x[dir]; |
285 | y = op->y + freearr_y[dir]; |
286 | y = op->y + freearr_y[dir]; |
286 | |
287 | |
287 | if (!QUERY_FLAG (op, FLAG_CAN_ROLL) |
288 | if (!op->flag [FLAG_CAN_ROLL] |
288 | || (op->weight && random_roll (0, op->weight / 50000 - 1, pusher, PREFER_LOW) |
289 | || (op->weight && random_roll (0, op->weight / 50000 - 1, pusher, PREFER_LOW) |
289 | > pusher->stats.Str)) |
290 | > pusher->stats.Str)) |
290 | return 0; |
291 | return 0; |
291 | |
292 | |
292 | m = op->map; |
293 | m = op->map; |
… | |
… | |
342 | if (who->head != NULL) |
343 | if (who->head != NULL) |
343 | who = who->head; |
344 | who = who->head; |
344 | owner = who->owner; |
345 | owner = who->owner; |
345 | |
346 | |
346 | /* Wake up sleeping monsters that may be pushed */ |
347 | /* Wake up sleeping monsters that may be pushed */ |
347 | CLEAR_FLAG (who, FLAG_SLEEP); |
348 | who->clr_flag (FLAG_SLEEP); |
348 | |
349 | |
349 | /* player change place with his pets or summoned creature */ |
350 | /* player change place with his pets or summoned creature */ |
350 | /* TODO: allow multi arch pushing. Can't be very difficult */ |
351 | /* TODO: allow multi arch pushing. Can't be very difficult */ |
351 | if (who->more == NULL |
352 | if (who->more == NULL |
352 | && ((owner && owner->contr && pusher->contr && same_party (owner->contr->party, pusher->contr->party)) |
353 | && ((owner && owner->contr && pusher->contr && same_party (owner->contr->party, pusher->contr->party)) |
… | |
… | |
379 | /* We want ONLY become enemy of evil, unaggressive monster. We must RUN in them */ |
380 | /* We want ONLY become enemy of evil, unaggressive monster. We must RUN in them */ |
380 | /* In original we have here a unaggressive check only - that was the reason why */ |
381 | /* In original we have here a unaggressive check only - that was the reason why */ |
381 | /* we so often become an enemy of friendly monsters... */ |
382 | /* we so often become an enemy of friendly monsters... */ |
382 | /* funny: was they set to unaggressive 0 (= not so nice) they don't attack */ |
383 | /* funny: was they set to unaggressive 0 (= not so nice) they don't attack */ |
383 | if (owner != pusher && pusher->type == PLAYER && who->type != PLAYER && |
384 | if (owner != pusher && pusher->type == PLAYER && who->type != PLAYER && |
384 | !QUERY_FLAG (who, FLAG_FRIENDLY) && !QUERY_FLAG (who, FLAG_NEUTRAL)) |
385 | !who->flag [FLAG_FRIENDLY] && !who->flag [FLAG_NEUTRAL]) |
385 | { |
386 | { |
386 | if (pusher->contr->run_on) /* only when we run */ |
387 | if (pusher->contr->run_on) /* only when we run */ |
387 | { |
388 | { |
388 | new_draw_info_format (NDI_UNIQUE, 0, pusher, "You start to attack %s!!", &who->name); |
389 | new_draw_info_format (NDI_UNIQUE, 0, pusher, "You start to attack %s!!", &who->name); |
389 | CLEAR_FLAG (who, FLAG_UNAGGRESSIVE); /* the sucker don't like you anymore */ |
390 | who->clr_flag (FLAG_UNAGGRESSIVE); /* the sucker don't like you anymore */ |
390 | who->enemy = pusher; |
391 | who->enemy = pusher; |
391 | return 1; |
392 | return 1; |
392 | } |
393 | } |
393 | else |
394 | else |
394 | new_draw_info_format (NDI_UNIQUE, 0, pusher, "You avoid attacking %s. H<You have to run if you wish to attack unnagressive NPCs.>", &who->name); |
395 | new_draw_info_format (NDI_UNIQUE, 0, pusher, "You avoid attacking %s. H<You have to run if you wish to attack unnagressive NPCs.>", &who->name); |
395 | } |
396 | } |
396 | |
397 | |
397 | /* now, let's test stand still. we NEVER can push stand_still monsters. */ |
398 | /* now, let's test stand still. we NEVER can push stand_still monsters. */ |
398 | if (QUERY_FLAG (who, FLAG_STAND_STILL)) |
399 | if (who->flag [FLAG_STAND_STILL]) |
399 | { |
400 | { |
400 | new_draw_info_format (NDI_UNIQUE, 0, pusher, "You can't push %s. H<You simply can't.>", &who->name); |
401 | new_draw_info_format (NDI_UNIQUE, 0, pusher, "You can't push %s. H<You simply can't.>", &who->name); |
401 | return 0; |
402 | return 0; |
402 | } |
403 | } |
403 | |
404 | |
… | |
… | |
408 | * this pushes the other person away - its not a swap. |
409 | * this pushes the other person away - its not a swap. |
409 | */ |
410 | */ |
410 | |
411 | |
411 | str1 = (who->stats.Str > 0 ? who->stats.Str : who->level); |
412 | str1 = (who->stats.Str > 0 ? who->stats.Str : who->level); |
412 | str2 = (pusher->stats.Str > 0 ? pusher->stats.Str : pusher->level); |
413 | str2 = (pusher->stats.Str > 0 ? pusher->stats.Str : pusher->level); |
413 | if (QUERY_FLAG (who, FLAG_WIZ) || |
414 | if (who->flag [FLAG_WIZ] || |
414 | random_roll (str1, str1 * 5 / 2, who, PREFER_HIGH) >= |
415 | random_roll (str1, str1 * 5 / 2, who, PREFER_HIGH) >= |
415 | random_roll (str2, str2 * 5 / 2, pusher, PREFER_HIGH) || !who->move (dir)) |
416 | random_roll (str2, str2 * 5 / 2, pusher, PREFER_HIGH) || !who->move (dir)) |
416 | { |
417 | { |
417 | if (who->type == PLAYER) |
418 | if (who->type == PLAYER) |
418 | new_draw_info_format (NDI_UNIQUE, 0, who, "%s tried to push you.", &pusher->name); |
419 | new_draw_info_format (NDI_UNIQUE, 0, who, "%s tried to push you.", &pusher->name); |