1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | 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 |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | 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, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | 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 |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /* |
25 | /* |
25 | * Routines that is executed from objects based on their speed have been |
26 | * Routines that is executed from objects based on their speed have been |
26 | * collected in this file. |
27 | * collected in this file. |
27 | */ |
28 | */ |
28 | |
|
|
29 | #include <global.h> |
29 | #include <global.h> |
30 | #include <spells.h> |
30 | #include <spells.h> |
31 | #include <sproto.h> |
31 | #include <sproto.h> |
32 | |
32 | |
33 | /* The following removes doors. The functions check to see if similar |
33 | /* The following removes doors. The functions check to see if similar |
34 | * doors are next to the one that is being removed, and if so, set it |
34 | * doors are next to the one that is being removed, and if so, set it |
35 | * so those will be removed shortly (in a cascade like fashion.) |
35 | * so those will be removed shortly (in a cascade like fashion.) |
36 | */ |
36 | */ |
37 | |
|
|
38 | void |
37 | void |
39 | remove_door (object *op) |
38 | remove_door (object *op) |
40 | { |
39 | { |
41 | int i; |
40 | int i; |
42 | object *tmp; |
41 | object *tmp; |
… | |
… | |
265 | if (op->env->type == PLAYER) |
264 | if (op->env->type == PLAYER) |
266 | { |
265 | { |
267 | op->env->stats.food--; |
266 | op->env->stats.food--; |
268 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick..."); |
267 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick..."); |
269 | } |
268 | } |
|
|
269 | |
270 | (void) hit_player (op->env, op->stats.dam, op, AT_INTERNAL, 1); |
270 | hit_player (op->env, op->stats.dam, op, AT_INTERNAL, 1); |
271 | } |
271 | } |
272 | |
272 | |
273 | |
273 | |
274 | void |
274 | void |
275 | move_gate (object *op) |
275 | move_gate (object *op) |
… | |
… | |
1019 | /* This object will teleport someone to a different map |
1019 | /* This object will teleport someone to a different map |
1020 | and will also apply changes to the player from its inventory. |
1020 | and will also apply changes to the player from its inventory. |
1021 | This was invented for giving classes, but there's no reason it |
1021 | This was invented for giving classes, but there's no reason it |
1022 | can't be generalized. |
1022 | can't be generalized. |
1023 | */ |
1023 | */ |
1024 | |
|
|
1025 | void |
1024 | void |
1026 | move_player_changer (object *op) |
1025 | move_player_changer (object *op) |
1027 | { |
1026 | { |
1028 | object *player; |
1027 | object *player; |
1029 | object *walk; |
1028 | object *walk; |
1030 | char c; |
|
|
1031 | |
1029 | |
1032 | if (!op->above || !EXIT_PATH (op)) |
1030 | if (!op->above || !EXIT_PATH (op)) |
1033 | return; |
1031 | return; |
1034 | |
1032 | |
1035 | /* This isn't all that great - means that the player_mover |
1033 | /* This isn't all that great - means that the player_mover |
1036 | * needs to be on top. |
1034 | * needs to be on top. |
1037 | */ |
1035 | */ |
1038 | if (op->above->type == PLAYER) |
1036 | if (op->above->type == PLAYER) |
1039 | { |
1037 | { |
1040 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
1038 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
1041 | return; |
1039 | return; |
|
|
1040 | |
1042 | player = op->above; |
1041 | player = op->above; |
1043 | |
1042 | |
1044 | for (walk = op->inv; walk != NULL; walk = walk->below) |
1043 | for (walk = op->inv; walk; walk = walk->below) |
1045 | apply_changes_to_player (player, walk); |
1044 | apply_changes_to_player (player, walk); |
1046 | |
1045 | |
1047 | player->update_stats (); |
1046 | player->update_stats (); |
1048 | |
1047 | |
1049 | esrv_send_inventory (op->above, op->above); |
1048 | esrv_send_inventory (op->above, op->above); |
1050 | esrv_update_item (UPD_FACE, op->above, op->above); |
1049 | esrv_update_item (UPD_FACE, op->above, op->above); |
1051 | |
1050 | |
1052 | /* update players death & WoR home-position */ |
1051 | /* update players death & WoR home-position */ |
1053 | sscanf (EXIT_PATH (op), "%c", &c); |
1052 | if (*EXIT_PATH (op) == '/') |
1054 | if (c == '/') |
|
|
1055 | { |
1053 | { |
1056 | strcpy (player->contr->savebed_map, EXIT_PATH (op)); |
1054 | player->contr->savebed_map = EXIT_PATH (op); |
1057 | player->contr->bed_x = EXIT_X (op); |
1055 | player->contr->bed_x = EXIT_X (op); |
1058 | player->contr->bed_y = EXIT_Y (op); |
1056 | player->contr->bed_y = EXIT_Y (op); |
1059 | } |
1057 | } |
1060 | else |
1058 | else |
1061 | LOG (llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", &EXIT_PATH (op)); |
1059 | LOG (llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", &EXIT_PATH (op)); |
1062 | |
1060 | |
1063 | op->above->enter_exit (op); |
1061 | op->above->enter_exit (op); |
1064 | player->contr->save (); |
|
|
1065 | } |
1062 | } |
1066 | } |
1063 | } |
1067 | |
1064 | |
1068 | /* firewalls fire other spells. |
1065 | /* firewalls fire other spells. |
1069 | * The direction of the wall is stored in op->stats.sp. |
1066 | * The direction of the wall is stored in op->stats.sp. |