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 | } |
… | |
… | |
543 | { |
541 | { |
544 | object *payload = op->inv; |
542 | object *payload = op->inv; |
545 | |
543 | |
546 | if (payload == NULL) |
544 | if (payload == NULL) |
547 | return NULL; |
545 | return NULL; |
|
|
546 | |
548 | payload->remove (); |
547 | payload->remove (); |
549 | op->destroy (); |
548 | op->destroy (true); |
550 | return payload; |
549 | return payload; |
551 | } |
550 | } |
552 | |
551 | |
553 | case ARROW: |
552 | case ARROW: |
554 | if (op->has_active_speed ()) |
553 | if (op->has_active_speed ()) |
… | |
… | |
581 | fix_stopped_arrow (object *op) |
580 | fix_stopped_arrow (object *op) |
582 | { |
581 | { |
583 | if (rndm (0, 99) < op->stats.food) |
582 | if (rndm (0, 99) < op->stats.food) |
584 | { |
583 | { |
585 | /* Small chance of breaking */ |
584 | /* Small chance of breaking */ |
586 | op->destroy (); |
585 | op->destroy (true); |
587 | return NULL; |
586 | return NULL; |
588 | } |
587 | } |
589 | |
588 | |
590 | op->set_speed (0); |
589 | op->set_speed (0); |
591 | op->direction = 0; |
590 | op->direction = 0; |
… | |
… | |
857 | |
856 | |
858 | if (op->type == LAMP) |
857 | if (op->type == LAMP) |
859 | tmp->stats.food = op->stats.food - 1; |
858 | tmp->stats.food = op->stats.food - 1; |
860 | |
859 | |
861 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
860 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
|
|
861 | |
862 | if (env) |
862 | if (env) |
863 | { |
|
|
864 | tmp = env->insert (tmp); |
863 | 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 |
864 | else |
877 | { |
865 | { |
878 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
866 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
879 | if (j < 0) /* No free spot */ |
867 | if (j < 0) /* No free spot */ |
880 | tmp->destroy (); |
868 | tmp->destroy (); |
… | |
… | |
947 | else |
935 | else |
948 | { |
936 | { |
949 | /* Random teleporter */ |
937 | /* Random teleporter */ |
950 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
938 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
951 | return; |
939 | return; |
|
|
940 | |
952 | teleport (head, TELEPORTER, tmp); |
941 | teleport (head, TELEPORTER, tmp); |
953 | } |
942 | } |
954 | } |
943 | } |
955 | |
944 | |
956 | /* This object will teleport someone to a different map |
945 | /* This object will teleport someone to a different map |
… | |
… | |
1191 | if (rndm (0, i) == 0) |
1180 | if (rndm (0, i) == 0) |
1192 | { |
1181 | { |
1193 | ob_to_copy = ob; |
1182 | ob_to_copy = ob; |
1194 | } |
1183 | } |
1195 | } |
1184 | } |
1196 | new_ob = object_create_clone (ob_to_copy); |
1185 | new_ob = ob_to_copy->deep_clone (); |
1197 | CLEAR_FLAG (new_ob, FLAG_IS_A_TEMPLATE); |
1186 | CLEAR_FLAG (new_ob, FLAG_IS_A_TEMPLATE); |
1198 | unflag_inv (new_ob, FLAG_IS_A_TEMPLATE); |
1187 | unflag_inv (new_ob, FLAG_IS_A_TEMPLATE); |
1199 | } |
1188 | } |
1200 | else |
1189 | else |
1201 | { |
1190 | { |
1202 | if (creator->other_arch == NULL) |
1191 | if (!creator->other_arch) |
1203 | { |
1192 | { |
1204 | LOG (llevError, "move_creator: Creator doesn't have other arch set: %s (%s, %d, %d)\n", |
1193 | LOG (llevError, "move_creator: Creator doesn't have other arch set: %s (%s, %d, %d)\n", |
1205 | &creator->name, &creator->map->path, creator->x, creator->y); |
1194 | &creator->name, &creator->map->path, creator->x, creator->y); |
1206 | return; |
1195 | return; |
1207 | } |
1196 | } |
… | |
… | |
1310 | { |
1299 | { |
1311 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1300 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1312 | remove_force (op); |
1301 | remove_force (op); |
1313 | else |
1302 | else |
1314 | { |
1303 | { |
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 (); |
1304 | op->remove (); |
1320 | |
1305 | |
1321 | if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) |
1306 | if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) |
1322 | make_sure_not_seen (op); |
1307 | make_sure_not_seen (op); |
1323 | |
1308 | |