… | |
… | |
58 | tmp->y = op->y; |
58 | tmp->y = op->y; |
59 | tmp->map = op->map; |
59 | tmp->map = op->map; |
60 | tmp->level = op->level; |
60 | tmp->level = op->level; |
61 | insert_ob_in_map (tmp, op->map, op, 0); |
61 | insert_ob_in_map (tmp, op->map, op, 0); |
62 | } |
62 | } |
63 | remove_ob (op); |
63 | op->remove (); |
64 | free_object (op); |
64 | op->destroy (0); |
65 | } |
65 | } |
66 | |
66 | |
67 | void |
67 | void |
68 | remove_door2 (object *op) |
68 | remove_door2 (object *op) |
69 | { |
69 | { |
… | |
… | |
87 | tmp->y = op->y; |
87 | tmp->y = op->y; |
88 | tmp->map = op->map; |
88 | tmp->map = op->map; |
89 | tmp->level = op->level; |
89 | tmp->level = op->level; |
90 | insert_ob_in_map (tmp, op->map, op, 0); |
90 | insert_ob_in_map (tmp, op->map, op, 0); |
91 | } |
91 | } |
92 | remove_ob (op); |
92 | op->remove (); |
93 | free_object (op); |
93 | op->destroy (0); |
94 | } |
94 | } |
95 | |
95 | |
96 | /* Will generate a monster according to content |
96 | /* Will generate a monster according to content |
97 | * of generator. |
97 | * of generator. |
98 | */ |
98 | */ |
… | |
… | |
220 | CLEAR_FLAG (op, FLAG_APPLIED); |
220 | CLEAR_FLAG (op, FLAG_APPLIED); |
221 | change_abil (op->env, op); |
221 | change_abil (op->env, op); |
222 | fix_player (op->env); |
222 | fix_player (op->env); |
223 | } |
223 | } |
224 | } |
224 | } |
225 | remove_ob (op); |
225 | op->remove (); |
226 | free_object (op); |
226 | op->destroy (0); |
227 | } |
227 | } |
228 | |
228 | |
229 | void |
229 | void |
230 | remove_blindness (object *op) |
230 | remove_blindness (object *op) |
231 | { |
231 | { |
… | |
… | |
235 | if (op->env != NULL) |
235 | if (op->env != NULL) |
236 | { |
236 | { |
237 | change_abil (op->env, op); |
237 | change_abil (op->env, op); |
238 | fix_player (op->env); |
238 | fix_player (op->env); |
239 | } |
239 | } |
240 | remove_ob (op); |
240 | op->remove (); |
241 | free_object (op); |
241 | op->destroy (0); |
242 | } |
242 | } |
243 | |
243 | |
244 | void |
244 | void |
245 | poison_more (object *op) |
245 | poison_more (object *op) |
246 | { |
246 | { |
247 | if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) |
247 | if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) |
248 | { |
248 | { |
249 | remove_ob (op); |
249 | op->remove (); |
250 | free_object (op); |
250 | op->destroy (0); |
251 | return; |
251 | return; |
252 | } |
252 | } |
253 | if (op->stats.food == 1) |
253 | if (op->stats.food == 1) |
254 | { |
254 | { |
255 | /* need to remove the object before fix_player is called, else fix_player |
255 | /* need to remove the object before fix_player is called, else fix_player |
… | |
… | |
259 | { |
259 | { |
260 | CLEAR_FLAG (op, FLAG_APPLIED); |
260 | CLEAR_FLAG (op, FLAG_APPLIED); |
261 | fix_player (op->env); |
261 | fix_player (op->env); |
262 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now."); |
262 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now."); |
263 | } |
263 | } |
264 | remove_ob (op); |
264 | op->remove (); |
265 | free_object (op); |
265 | op->destroy (0); |
266 | return; |
266 | return; |
267 | } |
267 | } |
268 | if (op->env->type == PLAYER) |
268 | if (op->env->type == PLAYER) |
269 | { |
269 | { |
270 | op->env->stats.food--; |
270 | op->env->stats.food--; |
… | |
… | |
280 | object *tmp; |
280 | object *tmp; |
281 | |
281 | |
282 | if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) |
282 | if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) |
283 | { |
283 | { |
284 | LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op)); |
284 | LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op)); |
285 | dump_object (op); |
|
|
286 | LOG (llevError, "%s\n", errmsg); |
|
|
287 | op->stats.wc = 0; |
285 | op->stats.wc = 0; |
288 | } |
286 | } |
289 | |
287 | |
290 | /* We're going down */ |
288 | /* We're going down */ |
291 | if (op->value) |
289 | if (op->value) |
… | |
… | |
384 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
382 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
385 | |
383 | |
386 | /* If there is a free spot, move the object someplace */ |
384 | /* If there is a free spot, move the object someplace */ |
387 | if (i != -1) |
385 | if (i != -1) |
388 | { |
386 | { |
389 | remove_ob (tmp); |
387 | tmp->remove (); |
390 | tmp->x += freearr_x[i], tmp->y += freearr_y[i]; |
388 | tmp->x += freearr_x[i], tmp->y += freearr_y[i]; |
391 | insert_ob_in_map (tmp, op->map, op, 0); |
389 | insert_ob_in_map (tmp, op->map, op, 0); |
392 | } |
390 | } |
393 | } |
391 | } |
394 | } |
392 | } |
… | |
… | |
593 | { |
591 | { |
594 | object *payload = op->inv; |
592 | object *payload = op->inv; |
595 | |
593 | |
596 | if (payload == NULL) |
594 | if (payload == NULL) |
597 | return NULL; |
595 | return NULL; |
598 | remove_ob (payload); |
596 | payload->remove (); |
599 | remove_ob (op); |
597 | op->remove (); |
600 | free_object (op); |
598 | op->destroy (0); |
601 | return payload; |
599 | return payload; |
602 | } |
600 | } |
603 | |
601 | |
604 | case ARROW: |
602 | case ARROW: |
605 | if (op->speed >= MIN_ACTIVE_SPEED) |
603 | if (op->speed >= MIN_ACTIVE_SPEED) |
… | |
… | |
632 | fix_stopped_arrow (object *op) |
630 | fix_stopped_arrow (object *op) |
633 | { |
631 | { |
634 | if (rndm (0, 99) < op->stats.food) |
632 | if (rndm (0, 99) < op->stats.food) |
635 | { |
633 | { |
636 | /* Small chance of breaking */ |
634 | /* Small chance of breaking */ |
637 | remove_ob (op); |
635 | op->remove (); |
638 | free_object (op); |
636 | op->destroy (0); |
639 | return NULL; |
637 | return NULL; |
640 | } |
638 | } |
641 | |
639 | |
642 | op->direction = 0; |
640 | op->direction = 0; |
643 | op->move_on = 0; |
641 | op->move_on = 0; |
… | |
… | |
687 | |
685 | |
688 | if (op->inv) |
686 | if (op->inv) |
689 | { |
687 | { |
690 | object *payload = op->inv; |
688 | object *payload = op->inv; |
691 | |
689 | |
692 | remove_ob (payload); |
690 | payload->remove (); |
693 | clear_owner (payload); |
691 | clear_owner (payload); |
694 | insert_ob_in_map (payload, op->map, payload, 0); |
692 | insert_ob_in_map (payload, op->map, payload, 0); |
695 | remove_ob (op); |
693 | op->remove (); |
696 | free_object (op); |
694 | op->destroy (0); |
697 | } |
695 | } |
698 | else |
696 | else |
699 | { |
697 | { |
700 | op = fix_stopped_arrow (op); |
698 | op = fix_stopped_arrow (op); |
701 | if (op) |
699 | if (op) |
… | |
… | |
715 | maptile *m; |
713 | maptile *m; |
716 | |
714 | |
717 | if (op->map == NULL) |
715 | if (op->map == NULL) |
718 | { |
716 | { |
719 | LOG (llevError, "BUG: Arrow had no map.\n"); |
717 | LOG (llevError, "BUG: Arrow had no map.\n"); |
720 | remove_ob (op); |
718 | op->remove (); |
721 | free_object (op); |
719 | op->destroy (0); |
722 | return; |
720 | return; |
723 | } |
721 | } |
724 | |
722 | |
725 | /* we need to stop thrown objects at some point. Like here. */ |
723 | /* we need to stop thrown objects at some point. Like here. */ |
726 | if (op->type == THROWN_OBJ) |
724 | if (op->type == THROWN_OBJ) |
… | |
… | |
733 | * bomb code, but there are potential other cases where that could happen, |
731 | * bomb code, but there are potential other cases where that could happen, |
734 | * and it is easy enough to clean it up here. |
732 | * and it is easy enough to clean it up here. |
735 | */ |
733 | */ |
736 | if (op->inv == NULL) |
734 | if (op->inv == NULL) |
737 | { |
735 | { |
738 | remove_ob (op); |
736 | op->remove (); |
739 | free_object (op); |
737 | op->destroy (0); |
740 | return; |
738 | return; |
741 | } |
739 | } |
|
|
740 | |
742 | if (op->last_sp-- < 0) |
741 | if (op->last_sp-- < 0) |
743 | { |
742 | { |
744 | stop_arrow (op); |
743 | stop_arrow (op); |
745 | return; |
744 | return; |
746 | } |
745 | } |
… | |
… | |
773 | { |
772 | { |
774 | for (tmp = get_map_ob (m, new_x, new_y); tmp != NULL; tmp = tmp->above) |
773 | for (tmp = get_map_ob (m, new_x, new_y); tmp != NULL; tmp = tmp->above) |
775 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
774 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
776 | break; |
775 | break; |
777 | |
776 | |
778 | |
|
|
779 | /* Not really fair, but don't let monsters hit themselves with |
777 | /* Not really fair, but don't let monsters hit themselves with |
780 | * their own arrow - this can be because they fire it then |
778 | * their own arrow - this can be because they fire it then |
781 | * move into it. |
779 | * move into it. |
782 | */ |
780 | */ |
783 | |
|
|
784 | if (tmp != NULL && tmp != op->owner) |
781 | if (tmp && tmp != op->owner) |
785 | { |
782 | { |
786 | /* Found living object, but it is reflecting the missile. Update |
783 | /* Found living object, but it is reflecting the missile. Update |
787 | * as below. (Note that for living creatures there is a small |
784 | * as below. (Note that for living creatures there is a small |
788 | * chance that reflect_missile fails.) |
785 | * chance that reflect_missile fails.) |
789 | */ |
786 | */ |
790 | |
|
|
791 | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) |
787 | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) |
792 | { |
788 | { |
793 | |
|
|
794 | int number = op->face->number; |
789 | int number = op->face->number; |
795 | |
790 | |
796 | op->direction = absdir (op->direction + 4); |
791 | op->direction = absdir (op->direction + 4); |
797 | op->state = 0; |
792 | op->state = 0; |
|
|
793 | |
798 | if (GET_ANIM_ID (op)) |
794 | if (GET_ANIM_ID (op)) |
799 | { |
795 | { |
800 | number += 4; |
796 | number += 4; |
|
|
797 | |
801 | if (number > GET_ANIMATION (op, 8)) |
798 | if (number > GET_ANIMATION (op, 8)) |
802 | number -= 8; |
799 | number -= 8; |
|
|
800 | |
803 | op->face = &new_faces[number]; |
801 | op->face = &new_faces[number]; |
804 | } |
802 | } |
|
|
803 | |
805 | was_reflected = 1; /* skip normal movement calculations */ |
804 | was_reflected = 1; /* skip normal movement calculations */ |
806 | } |
805 | } |
807 | else |
806 | else |
808 | { |
807 | { |
809 | /* Attack the object. */ |
808 | /* Attack the object. */ |
810 | op = hit_with_arrow (op, tmp); |
809 | op = hit_with_arrow (op, tmp); |
|
|
810 | |
811 | if (op == NULL) |
811 | if (!op) |
812 | return; |
812 | return; |
813 | } |
813 | } |
814 | } /* if this is not hitting its owner */ |
814 | } /* if this is not hitting its owner */ |
815 | } /* if there is something alive on this space */ |
815 | } /* if there is something alive on this space */ |
816 | |
|
|
817 | |
816 | |
818 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
817 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
819 | { |
818 | { |
820 | int retry = 0; |
819 | int retry = 0; |
821 | |
820 | |
… | |
… | |
893 | SET_ANIMATION (op, op->direction); |
892 | SET_ANIMATION (op, op->direction); |
894 | } /* object is reflected */ |
893 | } /* object is reflected */ |
895 | } /* object ran into a wall */ |
894 | } /* object ran into a wall */ |
896 | |
895 | |
897 | /* Move the arrow. */ |
896 | /* Move the arrow. */ |
898 | remove_ob (op); |
897 | op->remove (); |
899 | op->x = new_x; |
898 | op->x = new_x; |
900 | op->y = new_y; |
899 | op->y = new_y; |
901 | |
900 | |
902 | /* decrease the speed as it flies. 0.05 means a standard bow will shoot |
901 | /* decrease the speed as it flies. 0.05 means a standard bow will shoot |
903 | * about 17 squares. Tune as needed. |
902 | * about 17 squares. Tune as needed. |
… | |
… | |
929 | return; |
928 | return; |
930 | else |
929 | else |
931 | op->stats.food = 1; /* so 1 other_arch is made */ |
930 | op->stats.food = 1; /* so 1 other_arch is made */ |
932 | } |
931 | } |
933 | env = op->env; |
932 | env = op->env; |
934 | remove_ob (op); |
933 | op->remove (); |
935 | for (i = 0; i < NROFNEWOBJS (op); i++) |
934 | for (i = 0; i < NROFNEWOBJS (op); i++) |
936 | { |
935 | { |
937 | tmp = arch_to_object (op->other_arch); |
936 | tmp = arch_to_object (op->other_arch); |
938 | if (op->type == LAMP) |
937 | if (op->type == LAMP) |
939 | tmp->stats.food = op->stats.food - 1; |
938 | tmp->stats.food = op->stats.food - 1; |
… | |
… | |
954 | } |
953 | } |
955 | else |
954 | else |
956 | { |
955 | { |
957 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
956 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
958 | if (j == -1) /* No free spot */ |
957 | if (j == -1) /* No free spot */ |
959 | free_object (tmp); |
958 | tmp->destroy (0); |
960 | else |
959 | else |
961 | { |
960 | { |
962 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
961 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
963 | insert_ob_in_map (tmp, op->map, op, 0); |
962 | insert_ob_in_map (tmp, op->map, op, 0); |
964 | } |
963 | } |
965 | } |
964 | } |
966 | } |
965 | } |
967 | free_object (op); |
966 | op->destroy (0); |
968 | } |
967 | } |
969 | |
968 | |
970 | void |
969 | void |
971 | move_teleporter (object *op) |
970 | move_teleporter (object *op) |
972 | { |
971 | { |
… | |
… | |
1009 | else if (EXIT_X (head) || EXIT_Y (head)) |
1008 | else if (EXIT_X (head) || EXIT_Y (head)) |
1010 | { |
1009 | { |
1011 | if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head))) |
1010 | if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head))) |
1012 | { |
1011 | { |
1013 | LOG (llevError, "Removed illegal teleporter.\n"); |
1012 | LOG (llevError, "Removed illegal teleporter.\n"); |
1014 | remove_ob (head); |
1013 | head->remove (); |
1015 | free_object (head); |
1014 | head->destroy (0); |
1016 | return; |
1015 | return; |
1017 | } |
1016 | } |
1018 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
1017 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
1019 | return; |
1018 | return; |
1020 | transfer_ob (tmp, EXIT_X (head), EXIT_Y (head), 0, head); |
1019 | transfer_ob (tmp, EXIT_X (head), EXIT_Y (head), 0, head); |
… | |
… | |
1133 | if (victim->head) |
1132 | if (victim->head) |
1134 | victim = victim->head; |
1133 | victim = victim->head; |
1135 | |
1134 | |
1136 | if (QUERY_FLAG (op, FLAG_LIFESAVE) && op->stats.hp-- < 0) |
1135 | if (QUERY_FLAG (op, FLAG_LIFESAVE) && op->stats.hp-- < 0) |
1137 | { |
1136 | { |
1138 | remove_ob (op); |
1137 | op->remove (); |
1139 | free_object (op); |
1138 | op->destroy (0); |
1140 | return; |
1139 | return; |
1141 | } |
1140 | } |
1142 | nx = op->x + freearr_x[dir]; |
1141 | nx = op->x + freearr_x[dir]; |
1143 | ny = op->y + freearr_y[dir]; |
1142 | ny = op->y + freearr_y[dir]; |
1144 | m = op->map; |
1143 | m = op->map; |
… | |
… | |
1225 | { |
1224 | { |
1226 | if (strcmp (op->other_arch->name, tmp->arch->name) == 0) |
1225 | if (strcmp (op->other_arch->name, tmp->arch->name) == 0) |
1227 | { |
1226 | { |
1228 | if (op->level <= 0) |
1227 | if (op->level <= 0) |
1229 | { |
1228 | { |
1230 | remove_ob (tmp); |
1229 | tmp->remove (); |
1231 | free_object (tmp); |
1230 | tmp->destroy (0); |
1232 | } |
1231 | } |
1233 | else |
1232 | else |
1234 | { |
1233 | { |
1235 | uint64 new_nrof = (uint64) tmp->nrof * op->level; |
1234 | uint64 new_nrof = (uint64) tmp->nrof * op->level; |
1236 | |
1235 | |
… | |
… | |
1301 | } |
1300 | } |
1302 | |
1301 | |
1303 | /* Make sure this multipart object fits */ |
1302 | /* Make sure this multipart object fits */ |
1304 | if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y)) |
1303 | if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y)) |
1305 | { |
1304 | { |
1306 | free_object (new_ob); |
1305 | new_ob->destroy (0); |
1307 | return; |
1306 | return; |
1308 | } |
1307 | } |
1309 | |
1308 | |
1310 | insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y); |
1309 | insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y); |
1311 | if (QUERY_FLAG (new_ob, FLAG_FREED)) |
1310 | if (QUERY_FLAG (new_ob, FLAG_FREED)) |
… | |
… | |
1343 | break; |
1342 | break; |
1344 | } |
1343 | } |
1345 | |
1344 | |
1346 | if (tmp2) |
1345 | if (tmp2) |
1347 | { |
1346 | { |
1348 | remove_ob (tmp2); |
1347 | tmp2->remove (); |
1349 | free_object (tmp2); |
1348 | tmp2->destroy (0); |
1350 | } |
1349 | } |
1351 | |
1350 | |
1352 | /* cycle through his inventory to look for the MARK we want to |
1351 | /* cycle through his inventory to look for the MARK we want to |
1353 | * place |
1352 | * place |
1354 | */ |
1353 | */ |
… | |
… | |
1384 | { |
1383 | { |
1385 | op->stats.hp--; |
1384 | op->stats.hp--; |
1386 | if (op->stats.hp == 0) |
1385 | if (op->stats.hp == 0) |
1387 | { |
1386 | { |
1388 | /* marker expires--granted mark number limit */ |
1387 | /* marker expires--granted mark number limit */ |
1389 | remove_ob (op); |
1388 | op->remove (); |
1390 | free_object (op); |
1389 | op->destroy (0); |
1391 | return; |
1390 | return; |
1392 | } |
1391 | } |
1393 | } |
1392 | } |
1394 | } /* if tmp2 == NULL */ |
1393 | } /* if tmp2 == NULL */ |
1395 | } /* if tmp->type == PLAYER */ |
1394 | } /* if tmp->type == PLAYER */ |
… | |
… | |
1439 | object *pl = is_player_inv (op); |
1438 | object *pl = is_player_inv (op); |
1440 | |
1439 | |
1441 | if (pl) |
1440 | if (pl) |
1442 | esrv_del_item (pl->contr, op->count); |
1441 | esrv_del_item (pl->contr, op->count); |
1443 | |
1442 | |
1444 | remove_ob (op); |
1443 | op->remove (); |
1445 | |
1444 | |
1446 | if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) |
1445 | if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) |
1447 | make_sure_not_seen (op); |
1446 | make_sure_not_seen (op); |
1448 | |
1447 | |
1449 | free_object (op); |
1448 | op->destroy (0); |
1450 | } |
1449 | } |
1451 | |
1450 | |
1452 | return 1; |
1451 | return 1; |
1453 | } |
1452 | } |
1454 | |
1453 | |