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 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008 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 | * Deliantra 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 |
… | |
… | |
117 | |
117 | |
118 | dir = find_free_spot (op, gen->map, gen->x, gen->y, 1, SIZEOFFREE1 + 1); |
118 | dir = find_free_spot (op, gen->map, gen->x, gen->y, 1, SIZEOFFREE1 + 1); |
119 | if (dir < 0) |
119 | if (dir < 0) |
120 | return; |
120 | return; |
121 | |
121 | |
122 | op = object_create_clone (op); |
122 | op = op->deep_clone (); |
123 | |
123 | |
124 | CLEAR_FLAG (op, FLAG_IS_A_TEMPLATE); |
124 | CLEAR_FLAG (op, FLAG_IS_A_TEMPLATE); |
125 | unflag_inv (op, FLAG_IS_A_TEMPLATE); |
125 | unflag_inv (op, FLAG_IS_A_TEMPLATE); |
126 | } |
126 | } |
127 | else if (gen->other_arch) |
127 | else if (gen->other_arch) |
… | |
… | |
480 | } |
480 | } |
481 | |
481 | |
482 | void |
482 | void |
483 | move_hole (object *op) |
483 | move_hole (object *op) |
484 | { /* 1 = opening, 0 = closing */ |
484 | { /* 1 = opening, 0 = closing */ |
485 | object *next, *tmp; |
|
|
486 | |
|
|
487 | if (op->value) |
485 | if (op->value) |
488 | { /* We're opening */ |
486 | { /* We're opening */ |
489 | if (--op->stats.wc <= 0) |
487 | if (--op->stats.wc <= 0) |
490 | { /* Opened, let's stop */ |
488 | { /* Opened, let's stop */ |
491 | op->stats.wc = 0; |
489 | op->stats.wc = 0; |
492 | op->set_speed (0); |
490 | op->set_speed (0); |
493 | |
491 | |
494 | /* Hard coding this makes sense for holes I suppose */ |
492 | /* Hard coding this makes sense for holes I suppose */ |
495 | op->move_on = MOVE_WALK; |
493 | op->move_on = MOVE_WALK; |
496 | for (tmp = op->above; tmp != NULL; tmp = next) |
494 | for (object *next, *tmp = op->above; tmp; tmp = next) |
497 | { |
495 | { |
498 | next = tmp->above; |
496 | next = tmp->above; |
499 | move_apply (op, tmp, tmp); |
497 | move_apply (op, tmp, tmp); |
500 | } |
498 | } |
501 | } |
499 | } |
… | |
… | |
857 | |
855 | |
858 | if (op->type == LAMP) |
856 | if (op->type == LAMP) |
859 | tmp->stats.food = op->stats.food - 1; |
857 | tmp->stats.food = op->stats.food - 1; |
860 | |
858 | |
861 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
859 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
|
|
860 | |
862 | if (env) |
861 | if (env) |
863 | { |
|
|
864 | tmp = env->insert (tmp); |
862 | env->insert (tmp); |
865 | |
|
|
866 | /* If this object is the players inventory, we need to tell the |
|
|
867 | * client of the change. Insert_ob_in_map takes care of the |
|
|
868 | * updating the client, so we don't need to do that below. |
|
|
869 | */ |
|
|
870 | if (object *pl = op->in_player ()) |
|
|
871 | { |
|
|
872 | esrv_del_item (pl->contr, op->count); |
|
|
873 | esrv_send_item (pl, tmp); |
|
|
874 | } |
|
|
875 | } |
|
|
876 | else |
863 | else |
877 | { |
864 | { |
878 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
865 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
879 | if (j < 0) /* No free spot */ |
866 | if (j < 0) /* No free spot */ |
880 | tmp->destroy (); |
867 | tmp->destroy (); |
… | |
… | |
947 | else |
934 | else |
948 | { |
935 | { |
949 | /* Random teleporter */ |
936 | /* Random teleporter */ |
950 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
937 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
951 | return; |
938 | return; |
|
|
939 | |
952 | teleport (head, TELEPORTER, tmp); |
940 | teleport (head, TELEPORTER, tmp); |
953 | } |
941 | } |
954 | } |
942 | } |
955 | |
943 | |
956 | /* This object will teleport someone to a different map |
944 | /* This object will teleport someone to a different map |
… | |
… | |
1191 | if (rndm (0, i) == 0) |
1179 | if (rndm (0, i) == 0) |
1192 | { |
1180 | { |
1193 | ob_to_copy = ob; |
1181 | ob_to_copy = ob; |
1194 | } |
1182 | } |
1195 | } |
1183 | } |
1196 | new_ob = object_create_clone (ob_to_copy); |
1184 | new_ob = ob_to_copy->deep_clone (); |
1197 | CLEAR_FLAG (new_ob, FLAG_IS_A_TEMPLATE); |
1185 | CLEAR_FLAG (new_ob, FLAG_IS_A_TEMPLATE); |
1198 | unflag_inv (new_ob, FLAG_IS_A_TEMPLATE); |
1186 | unflag_inv (new_ob, FLAG_IS_A_TEMPLATE); |
1199 | } |
1187 | } |
1200 | else |
1188 | else |
1201 | { |
1189 | { |
… | |
… | |
1310 | { |
1298 | { |
1311 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1299 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1312 | remove_force (op); |
1300 | remove_force (op); |
1313 | else |
1301 | else |
1314 | { |
1302 | { |
1315 | /* If necessary, delete the item from the players inventory */ |
|
|
1316 | if (object *pl = op->in_player ()) |
|
|
1317 | esrv_del_item (pl->contr, op->count); |
|
|
1318 | |
|
|
1319 | op->remove (); |
1303 | op->remove (); |
1320 | |
1304 | |
1321 | if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) |
1305 | if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) |
1322 | make_sure_not_seen (op); |
1306 | make_sure_not_seen (op); |
1323 | |
1307 | |