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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2002 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 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. |
… | |
… | |
50 | } |
50 | } |
51 | } |
51 | } |
52 | |
52 | |
53 | if (op->other_arch) |
53 | if (op->other_arch) |
54 | { |
54 | { |
55 | object *tmp = arch_to_object (op->other_arch); |
55 | object *tmp = op->other_arch->instance (); |
56 | tmp->x = op->x; |
56 | tmp->x = op->x; |
57 | tmp->y = op->y; |
57 | tmp->y = op->y; |
58 | tmp->map = op->map; |
58 | tmp->map = op->map; |
59 | tmp->level = op->level; |
59 | tmp->level = op->level; |
60 | insert_ob_in_map (tmp, op->map, op, 0); |
60 | insert_ob_in_map (tmp, op->map, op, 0); |
… | |
… | |
79 | } |
79 | } |
80 | } |
80 | } |
81 | |
81 | |
82 | if (op->other_arch) |
82 | if (op->other_arch) |
83 | { |
83 | { |
84 | tmp = arch_to_object (op->other_arch); |
84 | tmp = op->other_arch->instance (); |
85 | tmp->x = op->x; |
85 | tmp->x = op->x; |
86 | tmp->y = op->y; |
86 | tmp->y = op->y; |
87 | tmp->map = op->map; |
87 | tmp->map = op->map; |
88 | tmp->level = op->level; |
88 | tmp->level = op->level; |
89 | insert_ob_in_map (tmp, op->map, op, 0); |
89 | insert_ob_in_map (tmp, op->map, op, 0); |
… | |
… | |
135 | // ...or use other_arch |
135 | // ...or use other_arch |
136 | dir = find_free_spot (gen->other_arch, gen->map, gen->x, gen->y, 1, SIZEOFFREE1 + 1); |
136 | dir = find_free_spot (gen->other_arch, gen->map, gen->x, gen->y, 1, SIZEOFFREE1 + 1); |
137 | if (dir < 0) |
137 | if (dir < 0) |
138 | return; |
138 | return; |
139 | |
139 | |
140 | op = arch_to_object (gen->other_arch); |
140 | op = gen->other_arch->instance (); |
141 | } |
141 | } |
142 | else |
142 | else |
143 | return; |
143 | return; |
144 | |
144 | |
145 | op->expand_tail (); |
145 | op->expand_tail (); |
… | |
… | |
249 | if (op->value) |
249 | if (op->value) |
250 | { |
250 | { |
251 | if (--op->stats.wc <= 0) |
251 | if (--op->stats.wc <= 0) |
252 | { /* Reached bottom, let's stop */ |
252 | { /* Reached bottom, let's stop */ |
253 | op->stats.wc = 0; |
253 | op->stats.wc = 0; |
254 | if (op->arch->speed) |
254 | if (op->arch->has_active_speed ()) |
255 | op->value = 0; |
255 | op->value = 0; |
256 | else |
256 | else |
257 | op->set_speed (0); |
257 | op->set_speed (0); |
258 | } |
258 | } |
259 | |
259 | |
… | |
… | |
285 | if (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || QUERY_FLAG (tmp, FLAG_ALIVE)) |
285 | if (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || QUERY_FLAG (tmp, FLAG_ALIVE)) |
286 | break; |
286 | break; |
287 | |
287 | |
288 | if (!tmp) |
288 | if (!tmp) |
289 | { |
289 | { |
290 | if (op->arch->speed) |
290 | if (op->arch->has_active_speed ()) |
291 | op->value = 1; |
291 | op->value = 1; |
292 | else |
292 | else |
293 | op->set_speed (0); |
293 | op->set_speed (0); |
294 | |
294 | |
295 | return; |
295 | return; |
… | |
… | |
827 | } |
827 | } |
828 | |
828 | |
829 | static void |
829 | static void |
830 | change_object (object *op) |
830 | change_object (object *op) |
831 | { /* Doesn`t handle linked objs yet */ |
831 | { /* Doesn`t handle linked objs yet */ |
832 | int i, j; |
|
|
833 | |
|
|
834 | if (!op->other_arch) |
832 | if (!op->other_arch) |
835 | { |
833 | { |
836 | LOG (llevError, "Change object (%s) without other_arch error.\n", op->debug_desc ()); |
834 | LOG (llevError, "Change object (%s) without other_arch error.\n", op->debug_desc ()); |
837 | return; |
835 | return; |
838 | } |
836 | } |
… | |
… | |
847 | } |
845 | } |
848 | |
846 | |
849 | object *env = op->env; |
847 | object *env = op->env; |
850 | |
848 | |
851 | op->remove (); |
849 | op->remove (); |
852 | for (i = 0; i < op->stats.food; i++) |
850 | for (int i = 0; i < op->stats.food; i++) |
853 | { |
851 | { |
854 | object *tmp = arch_to_object (op->other_arch); |
852 | object *tmp = op->other_arch->instance (); |
855 | |
853 | |
856 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
854 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
857 | |
855 | |
858 | if (env) |
856 | if (env) |
859 | env->insert (tmp); |
857 | env->insert (tmp); |
860 | else |
858 | else |
861 | { |
859 | { |
862 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
860 | int j = find_first_free_spot (tmp, op->map, op->x, op->y); |
|
|
861 | |
863 | if (j < 0) /* No free spot */ |
862 | if (j < 0) /* No free spot */ |
864 | tmp->destroy (); |
863 | tmp->destroy (); |
865 | else |
864 | else |
866 | { |
865 | { |
867 | mapxy pos (op); pos.move (j); |
866 | mapxy pos (op); pos.move (j); |
… | |
… | |
944 | can't be generalized. |
943 | can't be generalized. |
945 | */ |
944 | */ |
946 | static void |
945 | static void |
947 | move_player_changer (object *op) |
946 | move_player_changer (object *op) |
948 | { |
947 | { |
949 | object *player; |
|
|
950 | object *walk; |
|
|
951 | |
|
|
952 | if (!op->above || !EXIT_PATH (op)) |
948 | if (!op->above || !EXIT_PATH (op)) |
953 | return; |
949 | return; |
954 | |
950 | |
955 | /* This isn't all that great - means that the player_mover |
951 | /* This isn't all that great - means that the player_mover |
956 | * needs to be on top. |
952 | * needs to be on top. |
957 | */ |
953 | */ |
958 | if (op->above->type == PLAYER) |
954 | if (op->above->type == PLAYER) |
959 | { |
955 | { |
|
|
956 | object *player = op->above; |
|
|
957 | |
960 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
958 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
961 | return; |
959 | return; |
962 | |
960 | |
963 | player = op->above; |
|
|
964 | |
|
|
965 | for (walk = op->inv; walk; walk = walk->below) |
961 | for (object *walk = op->inv; walk; walk = walk->below) |
966 | apply_changes_to_player (player, walk); |
962 | apply_changes_to_player (player, walk); |
967 | |
963 | |
968 | player->update_stats (); |
964 | player->update_stats (); |
969 | |
965 | |
970 | esrv_send_inventory (op->above, op->above); |
966 | esrv_send_inventory (op->above, op->above); |
… | |
… | |
1082 | } |
1078 | } |
1083 | else |
1079 | else |
1084 | return; |
1080 | return; |
1085 | } |
1081 | } |
1086 | else |
1082 | else |
1087 | move_object (victim, dir); |
1083 | victim->move (dir); |
1088 | |
1084 | |
1089 | if (!op->stats.maxsp && op->attacktype) |
1085 | if (!op->stats.maxsp && op->attacktype) |
1090 | op->stats.maxsp = 2; |
1086 | op->stats.maxsp = 2; |
1091 | |
1087 | |
1092 | if (op->attacktype) |
1088 | if (op->attacktype) |
1093 | { /* flag to paralyze the player */ |
1089 | { /* flag to paralyze the player */ |
1094 | victim->speed_left = max (-5.f, -FABS (op->stats.maxsp * victim->speed / op->speed)); |
1090 | victim->speed_left = max (-5.f, -op->stats.maxsp * victim->speed / op->speed); |
1095 | } |
1091 | } |
1096 | } |
1092 | } |
1097 | } |
1093 | } |
1098 | } |
1094 | } |
1099 | |
1095 | |