… | |
… | |
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 | |
64 | free_object (op); |
64 | op->destroy (); |
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 | |
93 | free_object (op); |
93 | op->destroy (); |
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 | */ |
… | |
… | |
133 | if (rndm (0, 9)) |
133 | if (rndm (0, 9)) |
134 | generate_artifact (head, gen->map->difficulty); |
134 | generate_artifact (head, gen->map->difficulty); |
135 | insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]); |
135 | insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]); |
136 | if (QUERY_FLAG (head, FLAG_FREED)) |
136 | if (QUERY_FLAG (head, FLAG_FREED)) |
137 | return; |
137 | return; |
138 | if (HAS_RANDOM_ITEMS (head)) |
138 | if (head->has_random_items ()) |
139 | create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0); |
139 | create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0); |
140 | } |
140 | } |
141 | |
141 | |
142 | void |
142 | void |
143 | generate_monster_arch (object *gen) |
143 | generate_monster_arch (object *gen) |
… | |
… | |
175 | if (rndm (0, 9)) |
175 | if (rndm (0, 9)) |
176 | generate_artifact (op, gen->map->difficulty); |
176 | generate_artifact (op, gen->map->difficulty); |
177 | insert_ob_in_map (op, gen->map, gen, 0); |
177 | insert_ob_in_map (op, gen->map, gen, 0); |
178 | if (QUERY_FLAG (op, FLAG_FREED)) |
178 | if (QUERY_FLAG (op, FLAG_FREED)) |
179 | return; |
179 | return; |
180 | if (HAS_RANDOM_ITEMS (op)) |
180 | if (op->has_random_items ()) |
181 | create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); |
181 | create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); |
182 | if (head == NULL) |
182 | if (head == NULL) |
183 | head = op; |
183 | head = op; |
184 | prev = op; |
184 | prev = op; |
185 | at = at->more; |
185 | at = at->more; |
… | |
… | |
217 | default: |
217 | default: |
218 | if (op->env != NULL) |
218 | if (op->env != NULL) |
219 | { |
219 | { |
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 | op->env->update_stats (); |
223 | } |
223 | } |
224 | } |
224 | } |
225 | remove_ob (op); |
225 | |
226 | free_object (op); |
226 | op->destroy (); |
227 | } |
227 | } |
228 | |
228 | |
229 | void |
229 | void |
230 | remove_blindness (object *op) |
230 | remove_blindness (object *op) |
231 | { |
231 | { |
232 | if (--op->stats.food > 0) |
232 | if (--op->stats.food > 0) |
233 | return; |
233 | return; |
|
|
234 | |
234 | CLEAR_FLAG (op, FLAG_APPLIED); |
235 | CLEAR_FLAG (op, FLAG_APPLIED); |
|
|
236 | |
235 | if (op->env != NULL) |
237 | if (op->env != NULL) |
236 | { |
238 | { |
237 | change_abil (op->env, op); |
239 | change_abil (op->env, op); |
238 | fix_player (op->env); |
240 | op->env->update_stats (); |
239 | } |
241 | } |
240 | remove_ob (op); |
242 | |
241 | free_object (op); |
243 | op->destroy (); |
242 | } |
244 | } |
243 | |
245 | |
244 | void |
246 | void |
245 | poison_more (object *op) |
247 | poison_more (object *op) |
246 | { |
248 | { |
247 | if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) |
249 | if (op->env == NULL || !QUERY_FLAG (op->env, FLAG_ALIVE) || op->env->stats.hp < 0) |
248 | { |
250 | { |
249 | remove_ob (op); |
251 | op->destroy (); |
250 | free_object (op); |
|
|
251 | return; |
252 | return; |
252 | } |
253 | } |
|
|
254 | |
253 | if (op->stats.food == 1) |
255 | if (op->stats.food == 1) |
254 | { |
256 | { |
255 | /* need to remove the object before fix_player is called, else fix_player |
257 | /* need to remove the object before fix_player is called, else fix_player |
256 | * will not do anything. |
258 | * will not do anything. |
257 | */ |
259 | */ |
258 | if (op->env->type == PLAYER) |
260 | if (op->env->type == PLAYER) |
259 | { |
261 | { |
260 | CLEAR_FLAG (op, FLAG_APPLIED); |
262 | CLEAR_FLAG (op, FLAG_APPLIED); |
261 | fix_player (op->env); |
263 | op->env->update_stats (); |
262 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now."); |
264 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel much better now."); |
263 | } |
265 | } |
264 | remove_ob (op); |
266 | |
265 | free_object (op); |
267 | op->destroy (); |
266 | return; |
268 | return; |
267 | } |
269 | } |
|
|
270 | |
268 | if (op->env->type == PLAYER) |
271 | if (op->env->type == PLAYER) |
269 | { |
272 | { |
270 | op->env->stats.food--; |
273 | op->env->stats.food--; |
271 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick..."); |
274 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick..."); |
272 | } |
275 | } |
… | |
… | |
280 | object *tmp; |
283 | object *tmp; |
281 | |
284 | |
282 | if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) |
285 | if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) |
283 | { |
286 | { |
284 | LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op)); |
287 | 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; |
288 | op->stats.wc = 0; |
288 | } |
289 | } |
289 | |
290 | |
290 | /* We're going down */ |
291 | /* We're going down */ |
291 | if (op->value) |
292 | if (op->value) |
… | |
… | |
384 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
385 | int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); |
385 | |
386 | |
386 | /* If there is a free spot, move the object someplace */ |
387 | /* If there is a free spot, move the object someplace */ |
387 | if (i != -1) |
388 | if (i != -1) |
388 | { |
389 | { |
389 | remove_ob (tmp); |
390 | tmp->remove (); |
390 | tmp->x += freearr_x[i], tmp->y += freearr_y[i]; |
391 | tmp->x += freearr_x[i], tmp->y += freearr_y[i]; |
391 | insert_ob_in_map (tmp, op->map, op, 0); |
392 | insert_ob_in_map (tmp, op->map, op, 0); |
392 | } |
393 | } |
393 | } |
394 | } |
394 | } |
395 | } |
… | |
… | |
458 | int last = op->value; |
459 | int last = op->value; |
459 | int detected; |
460 | int detected; |
460 | |
461 | |
461 | detected = 0; |
462 | detected = 0; |
462 | |
463 | |
463 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL && !detected; tmp = tmp->above) |
464 | for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL && !detected; tmp = tmp->above) |
464 | { |
465 | { |
465 | object *tmp2; |
466 | object *tmp2; |
466 | |
467 | |
467 | if (op->stats.hp) |
468 | if (op->stats.hp) |
468 | { |
469 | { |
… | |
… | |
593 | { |
594 | { |
594 | object *payload = op->inv; |
595 | object *payload = op->inv; |
595 | |
596 | |
596 | if (payload == NULL) |
597 | if (payload == NULL) |
597 | return NULL; |
598 | return NULL; |
598 | remove_ob (payload); |
599 | payload->remove (); |
599 | remove_ob (op); |
600 | op->destroy (); |
600 | free_object (op); |
|
|
601 | return payload; |
601 | return payload; |
602 | } |
602 | } |
603 | |
603 | |
604 | case ARROW: |
604 | case ARROW: |
605 | if (op->speed >= MIN_ACTIVE_SPEED) |
605 | if (op->speed >= MIN_ACTIVE_SPEED) |
… | |
… | |
632 | fix_stopped_arrow (object *op) |
632 | fix_stopped_arrow (object *op) |
633 | { |
633 | { |
634 | if (rndm (0, 99) < op->stats.food) |
634 | if (rndm (0, 99) < op->stats.food) |
635 | { |
635 | { |
636 | /* Small chance of breaking */ |
636 | /* Small chance of breaking */ |
637 | remove_ob (op); |
637 | op->destroy (); |
638 | free_object (op); |
|
|
639 | return NULL; |
638 | return NULL; |
640 | } |
639 | } |
641 | |
640 | |
642 | op->direction = 0; |
641 | op->direction = 0; |
643 | op->move_on = 0; |
642 | op->move_on = 0; |
… | |
… | |
657 | op->spellarg = NULL; |
656 | op->spellarg = NULL; |
658 | } |
657 | } |
659 | else |
658 | else |
660 | op->slaying = NULL; |
659 | op->slaying = NULL; |
661 | |
660 | |
662 | /* Reset these to zero, so that CAN_MERGE will work properly */ |
661 | /* Reset these to zero, so that object::can_merge will work properly */ |
663 | op->spellarg = NULL; |
662 | op->spellarg = NULL; |
664 | op->stats.sp = 0; |
663 | op->stats.sp = 0; |
665 | op->stats.hp = 0; |
664 | op->stats.hp = 0; |
666 | op->stats.grace = 0; |
665 | op->stats.grace = 0; |
667 | op->level = 0; |
666 | op->level = 0; |
… | |
… | |
687 | |
686 | |
688 | if (op->inv) |
687 | if (op->inv) |
689 | { |
688 | { |
690 | object *payload = op->inv; |
689 | object *payload = op->inv; |
691 | |
690 | |
692 | remove_ob (payload); |
691 | payload->remove (); |
693 | clear_owner (payload); |
692 | payload->owner = 0; |
694 | insert_ob_in_map (payload, op->map, payload, 0); |
693 | insert_ob_in_map (payload, op->map, payload, 0); |
695 | remove_ob (op); |
694 | op->destroy (); |
696 | free_object (op); |
|
|
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->destroy (); |
721 | free_object (op); |
|
|
722 | return; |
719 | return; |
723 | } |
720 | } |
724 | |
721 | |
725 | /* we need to stop thrown objects at some point. Like here. */ |
722 | /* we need to stop thrown objects at some point. Like here. */ |
726 | if (op->type == THROWN_OBJ) |
723 | if (op->type == THROWN_OBJ) |
… | |
… | |
733 | * bomb code, but there are potential other cases where that could happen, |
730 | * bomb code, but there are potential other cases where that could happen, |
734 | * and it is easy enough to clean it up here. |
731 | * and it is easy enough to clean it up here. |
735 | */ |
732 | */ |
736 | if (op->inv == NULL) |
733 | if (op->inv == NULL) |
737 | { |
734 | { |
738 | remove_ob (op); |
735 | op->destroy (); |
739 | free_object (op); |
|
|
740 | return; |
736 | return; |
741 | } |
737 | } |
|
|
738 | |
742 | if (op->last_sp-- < 0) |
739 | if (op->last_sp-- < 0) |
743 | { |
740 | { |
744 | stop_arrow (op); |
741 | stop_arrow (op); |
745 | return; |
742 | return; |
746 | } |
743 | } |
… | |
… | |
769 | } |
766 | } |
770 | |
767 | |
771 | /* only need to look for living creatures if this flag is set */ |
768 | /* only need to look for living creatures if this flag is set */ |
772 | if (mflags & P_IS_ALIVE) |
769 | if (mflags & P_IS_ALIVE) |
773 | { |
770 | { |
774 | for (tmp = get_map_ob (m, new_x, new_y); tmp != NULL; tmp = tmp->above) |
771 | for (tmp = GET_MAP_OB (m, new_x, new_y); tmp != NULL; tmp = tmp->above) |
775 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
772 | if (QUERY_FLAG (tmp, FLAG_ALIVE)) |
776 | break; |
773 | break; |
777 | |
|
|
778 | |
774 | |
779 | /* Not really fair, but don't let monsters hit themselves with |
775 | /* Not really fair, but don't let monsters hit themselves with |
780 | * their own arrow - this can be because they fire it then |
776 | * their own arrow - this can be because they fire it then |
781 | * move into it. |
777 | * move into it. |
782 | */ |
778 | */ |
783 | |
|
|
784 | if (tmp != NULL && tmp != op->owner) |
779 | if (tmp && tmp != op->owner) |
785 | { |
780 | { |
786 | /* Found living object, but it is reflecting the missile. Update |
781 | /* Found living object, but it is reflecting the missile. Update |
787 | * as below. (Note that for living creatures there is a small |
782 | * as below. (Note that for living creatures there is a small |
788 | * chance that reflect_missile fails.) |
783 | * chance that reflect_missile fails.) |
789 | */ |
784 | */ |
790 | |
|
|
791 | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) |
785 | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) |
792 | { |
786 | { |
793 | |
|
|
794 | int number = op->face->number; |
787 | int number = op->face->number; |
795 | |
788 | |
796 | op->direction = absdir (op->direction + 4); |
789 | op->direction = absdir (op->direction + 4); |
797 | op->state = 0; |
790 | op->state = 0; |
|
|
791 | |
798 | if (GET_ANIM_ID (op)) |
792 | if (GET_ANIM_ID (op)) |
799 | { |
793 | { |
800 | number += 4; |
794 | number += 4; |
|
|
795 | |
801 | if (number > GET_ANIMATION (op, 8)) |
796 | if (number > GET_ANIMATION (op, 8)) |
802 | number -= 8; |
797 | number -= 8; |
|
|
798 | |
803 | op->face = &new_faces[number]; |
799 | op->face = &new_faces[number]; |
804 | } |
800 | } |
|
|
801 | |
805 | was_reflected = 1; /* skip normal movement calculations */ |
802 | was_reflected = 1; /* skip normal movement calculations */ |
806 | } |
803 | } |
807 | else |
804 | else |
808 | { |
805 | { |
809 | /* Attack the object. */ |
806 | /* Attack the object. */ |
810 | op = hit_with_arrow (op, tmp); |
807 | op = hit_with_arrow (op, tmp); |
|
|
808 | |
811 | if (op == NULL) |
809 | if (!op) |
812 | return; |
810 | return; |
813 | } |
811 | } |
814 | } /* if this is not hitting its owner */ |
812 | } /* if this is not hitting its owner */ |
815 | } /* if there is something alive on this space */ |
813 | } /* if there is something alive on this space */ |
816 | |
|
|
817 | |
814 | |
818 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
815 | if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) |
819 | { |
816 | { |
820 | int retry = 0; |
817 | int retry = 0; |
821 | |
818 | |
… | |
… | |
893 | SET_ANIMATION (op, op->direction); |
890 | SET_ANIMATION (op, op->direction); |
894 | } /* object is reflected */ |
891 | } /* object is reflected */ |
895 | } /* object ran into a wall */ |
892 | } /* object ran into a wall */ |
896 | |
893 | |
897 | /* Move the arrow. */ |
894 | /* Move the arrow. */ |
898 | remove_ob (op); |
895 | op->remove (); |
899 | op->x = new_x; |
896 | op->x = new_x; |
900 | op->y = new_y; |
897 | op->y = new_y; |
901 | |
898 | |
902 | /* decrease the speed as it flies. 0.05 means a standard bow will shoot |
899 | /* decrease the speed as it flies. 0.05 means a standard bow will shoot |
903 | * about 17 squares. Tune as needed. |
900 | * about 17 squares. Tune as needed. |
… | |
… | |
911 | * Modified this routine to allow held objects. b.t. */ |
908 | * Modified this routine to allow held objects. b.t. */ |
912 | |
909 | |
913 | void |
910 | void |
914 | change_object (object *op) |
911 | change_object (object *op) |
915 | { /* Doesn`t handle linked objs yet */ |
912 | { /* Doesn`t handle linked objs yet */ |
916 | object *tmp, *env, *pl; |
|
|
917 | int i, j; |
913 | int i, j; |
918 | |
914 | |
919 | if (op->other_arch == NULL) |
915 | if (op->other_arch == NULL) |
920 | { |
916 | { |
921 | LOG (llevError, "Change object (%s) without other_arch error.\n", &op->name); |
917 | LOG (llevError, "Change object (%s) without other_arch error.\n", &op->name); |
… | |
… | |
928 | if (op->stats.food-- > 0) |
924 | if (op->stats.food-- > 0) |
929 | return; |
925 | return; |
930 | else |
926 | else |
931 | op->stats.food = 1; /* so 1 other_arch is made */ |
927 | op->stats.food = 1; /* so 1 other_arch is made */ |
932 | } |
928 | } |
|
|
929 | |
|
|
930 | object *pl = op->in_player (); |
933 | env = op->env; |
931 | object *env = op->env; |
934 | remove_ob (op); |
932 | |
|
|
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 | object *tmp = arch_to_object (op->other_arch); |
|
|
937 | |
938 | if (op->type == LAMP) |
938 | if (op->type == LAMP) |
939 | tmp->stats.food = op->stats.food - 1; |
939 | tmp->stats.food = op->stats.food - 1; |
|
|
940 | |
940 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
941 | tmp->stats.hp = op->stats.hp; /* The only variable it keeps. */ |
941 | if (env) |
942 | if (env) |
942 | { |
943 | { |
943 | tmp->x = env->x, tmp->y = env->y; |
944 | tmp->x = env->x, tmp->y = env->y; |
944 | tmp = insert_ob_in_ob (tmp, env); |
945 | tmp = insert_ob_in_ob (tmp, env); |
|
|
946 | |
945 | /* If this object is the players inventory, we need to tell the |
947 | /* If this object is the players inventory, we need to tell the |
946 | * client of the change. Insert_ob_in_map takes care of the |
948 | * client of the change. Insert_ob_in_map takes care of the |
947 | * updating the client, so we don't need to do that below. |
949 | * updating the client, so we don't need to do that below. |
948 | */ |
950 | */ |
949 | if ((pl = is_player_inv (env)) != NULL) |
951 | if (pl) |
950 | { |
952 | { |
951 | esrv_del_item (pl->contr, op->count); |
953 | esrv_del_item (pl->contr, op->count); |
952 | esrv_send_item (pl, tmp); |
954 | esrv_send_item (pl, tmp); |
953 | } |
955 | } |
954 | } |
956 | } |
955 | else |
957 | else |
956 | { |
958 | { |
957 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
959 | j = find_first_free_spot (tmp, op->map, op->x, op->y); |
958 | if (j == -1) /* No free spot */ |
960 | if (j == -1) /* No free spot */ |
959 | free_object (tmp); |
961 | tmp->destroy (); |
960 | else |
962 | else |
961 | { |
963 | { |
962 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
964 | tmp->x = op->x + freearr_x[j], tmp->y = op->y + freearr_y[j]; |
963 | insert_ob_in_map (tmp, op->map, op, 0); |
965 | insert_ob_in_map (tmp, op->map, op, 0); |
964 | } |
966 | } |
965 | } |
967 | } |
966 | } |
968 | } |
967 | free_object (op); |
969 | |
|
|
970 | op->destroy (); |
968 | } |
971 | } |
969 | |
972 | |
970 | void |
973 | void |
971 | move_teleporter (object *op) |
974 | move_teleporter (object *op) |
972 | { |
975 | { |
… | |
… | |
1009 | else if (EXIT_X (head) || EXIT_Y (head)) |
1012 | else if (EXIT_X (head) || EXIT_Y (head)) |
1010 | { |
1013 | { |
1011 | if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head))) |
1014 | if (out_of_map (head->map, EXIT_X (head), EXIT_Y (head))) |
1012 | { |
1015 | { |
1013 | LOG (llevError, "Removed illegal teleporter.\n"); |
1016 | LOG (llevError, "Removed illegal teleporter.\n"); |
1014 | remove_ob (head); |
1017 | head->destroy (); |
1015 | free_object (head); |
|
|
1016 | return; |
1018 | return; |
1017 | } |
1019 | } |
|
|
1020 | |
1018 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
1021 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
1019 | return; |
1022 | return; |
|
|
1023 | |
1020 | transfer_ob (tmp, EXIT_X (head), EXIT_Y (head), 0, head); |
1024 | transfer_ob (tmp, EXIT_X (head), EXIT_Y (head), 0, head); |
1021 | } |
1025 | } |
1022 | else |
1026 | else |
1023 | { |
1027 | { |
1024 | /* Random teleporter */ |
1028 | /* Random teleporter */ |
… | |
… | |
1055 | player = op->above; |
1059 | player = op->above; |
1056 | |
1060 | |
1057 | for (walk = op->inv; walk != NULL; walk = walk->below) |
1061 | for (walk = op->inv; walk != NULL; walk = walk->below) |
1058 | apply_changes_to_player (player, walk); |
1062 | apply_changes_to_player (player, walk); |
1059 | |
1063 | |
1060 | fix_player (player); |
1064 | player->update_stats (); |
1061 | |
1065 | |
1062 | esrv_send_inventory (op->above, op->above); |
1066 | esrv_send_inventory (op->above, op->above); |
1063 | esrv_update_item (UPD_FACE, op->above, op->above); |
1067 | esrv_update_item (UPD_FACE, op->above, op->above); |
1064 | |
1068 | |
1065 | /* update players death & WoR home-position */ |
1069 | /* update players death & WoR home-position */ |
… | |
… | |
1072 | } |
1076 | } |
1073 | else |
1077 | else |
1074 | LOG (llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", &EXIT_PATH (op)); |
1078 | LOG (llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", &EXIT_PATH (op)); |
1075 | |
1079 | |
1076 | enter_exit (op->above, op); |
1080 | enter_exit (op->above, op); |
1077 | save_player (player, 1); |
1081 | player->contr->save (); |
1078 | } |
1082 | } |
1079 | } |
1083 | } |
1080 | |
1084 | |
1081 | /* firewalls fire other spells. |
1085 | /* firewalls fire other spells. |
1082 | * The direction of the wall is stored in op->stats.sp. |
1086 | * The direction of the wall is stored in op->stats.sp. |
… | |
… | |
1122 | |
1126 | |
1123 | /* Determine direction now for random movers so we do the right thing */ |
1127 | /* Determine direction now for random movers so we do the right thing */ |
1124 | if (!dir) |
1128 | if (!dir) |
1125 | dir = rndm (1, 8); |
1129 | dir = rndm (1, 8); |
1126 | |
1130 | |
1127 | for (victim = get_map_ob (op->map, op->x, op->y); victim != NULL; victim = victim->above) |
1131 | for (victim = GET_MAP_OB (op->map, op->x, op->y); victim != NULL; victim = victim->above) |
1128 | { |
1132 | { |
1129 | if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_WIZPASS) && |
1133 | if (QUERY_FLAG (victim, FLAG_ALIVE) && !QUERY_FLAG (victim, FLAG_WIZPASS) && |
1130 | (victim->move_type & op->move_type || !victim->move_type)) |
1134 | (victim->move_type & op->move_type || !victim->move_type)) |
1131 | { |
1135 | { |
1132 | |
1136 | |
1133 | if (victim->head) |
1137 | if (victim->head) |
1134 | victim = victim->head; |
1138 | victim = victim->head; |
1135 | |
1139 | |
1136 | if (QUERY_FLAG (op, FLAG_LIFESAVE) && op->stats.hp-- < 0) |
1140 | if (QUERY_FLAG (op, FLAG_LIFESAVE) && op->stats.hp-- < 0) |
1137 | { |
1141 | { |
1138 | remove_ob (op); |
1142 | op->remove (); |
1139 | free_object (op); |
|
|
1140 | return; |
1143 | return; |
1141 | } |
1144 | } |
|
|
1145 | |
1142 | nx = op->x + freearr_x[dir]; |
1146 | nx = op->x + freearr_x[dir]; |
1143 | ny = op->y + freearr_y[dir]; |
1147 | ny = op->y + freearr_y[dir]; |
1144 | m = op->map; |
1148 | m = op->map; |
1145 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) |
1149 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) |
1146 | { |
1150 | { |
… | |
… | |
1149 | } |
1153 | } |
1150 | |
1154 | |
1151 | if (should_director_abort (op, victim)) |
1155 | if (should_director_abort (op, victim)) |
1152 | return; |
1156 | return; |
1153 | |
1157 | |
1154 | for (nextmover = get_map_ob (m, nx, ny); nextmover != NULL; nextmover = nextmover->above) |
1158 | for (nextmover = GET_MAP_OB (m, nx, ny); nextmover != NULL; nextmover = nextmover->above) |
1155 | { |
1159 | { |
1156 | if (nextmover->type == PLAYERMOVER) |
1160 | if (nextmover->type == PLAYERMOVER) |
1157 | nextmover->speed_left = -.99; |
1161 | nextmover->speed_left = -.99; |
1158 | if (QUERY_FLAG (nextmover, FLAG_ALIVE)) |
1162 | if (QUERY_FLAG (nextmover, FLAG_ALIVE)) |
1159 | { |
1163 | { |
… | |
… | |
1224 | for (tmp = op->above; tmp != NULL; tmp = tmp->above) |
1228 | for (tmp = op->above; tmp != NULL; tmp = tmp->above) |
1225 | { |
1229 | { |
1226 | if (strcmp (op->other_arch->name, tmp->arch->name) == 0) |
1230 | if (strcmp (op->other_arch->name, tmp->arch->name) == 0) |
1227 | { |
1231 | { |
1228 | if (op->level <= 0) |
1232 | if (op->level <= 0) |
1229 | { |
1233 | tmp->destroy (); |
1230 | remove_ob (tmp); |
|
|
1231 | free_object (tmp); |
|
|
1232 | } |
|
|
1233 | else |
1234 | else |
1234 | { |
1235 | { |
1235 | uint64 new_nrof = (uint64) tmp->nrof * op->level; |
1236 | uint64 new_nrof = (uint64) tmp->nrof * op->level; |
1236 | |
1237 | |
1237 | if (new_nrof >= 1UL << 31) |
1238 | if (new_nrof >= 1UL << 31) |
1238 | new_nrof = 1UL << 31; |
1239 | new_nrof = 1UL << 31; |
|
|
1240 | |
1239 | tmp->nrof = new_nrof; |
1241 | tmp->nrof = new_nrof; |
1240 | } |
1242 | } |
|
|
1243 | |
1241 | break; |
1244 | break; |
1242 | } |
1245 | } |
1243 | } |
1246 | } |
1244 | } |
1247 | } |
1245 | |
1248 | |
… | |
… | |
1301 | } |
1304 | } |
1302 | |
1305 | |
1303 | /* Make sure this multipart object fits */ |
1306 | /* Make sure this multipart object fits */ |
1304 | if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y)) |
1307 | if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y)) |
1305 | { |
1308 | { |
1306 | free_object (new_ob); |
1309 | new_ob->destroy (); |
1307 | return; |
1310 | return; |
1308 | } |
1311 | } |
1309 | |
1312 | |
1310 | insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y); |
1313 | insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y); |
1311 | if (QUERY_FLAG (new_ob, FLAG_FREED)) |
1314 | if (QUERY_FLAG (new_ob, FLAG_FREED)) |
… | |
… | |
1327 | unless hp was zero to start with, in which case it is infinite.*/ |
1330 | unless hp was zero to start with, in which case it is infinite.*/ |
1328 | |
1331 | |
1329 | void |
1332 | void |
1330 | move_marker (object *op) |
1333 | move_marker (object *op) |
1331 | { |
1334 | { |
|
|
1335 | if (object *tmp = op->ms ().player ()) |
|
|
1336 | { |
1332 | object *tmp, *tmp2; |
1337 | object *tmp2; |
1333 | |
1338 | |
1334 | for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) |
|
|
1335 | { |
|
|
1336 | if (tmp->type == PLAYER) |
|
|
1337 | { /* we've got someone to MARK */ |
|
|
1338 | |
|
|
1339 | /* remove an old force with a slaying field == op->name */ |
1339 | /* remove an old force with a slaying field == op->name */ |
1340 | for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
1340 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1341 | { |
|
|
1342 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->name)) |
1341 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->name)) |
1343 | break; |
|
|
1344 | } |
|
|
1345 | |
|
|
1346 | if (tmp2) |
|
|
1347 | { |
1342 | { |
1348 | remove_ob (tmp2); |
1343 | tmp2->destroy (); |
1349 | free_object (tmp2); |
1344 | break; |
1350 | } |
1345 | } |
1351 | |
1346 | |
1352 | /* cycle through his inventory to look for the MARK we want to |
1347 | /* cycle through his inventory to look for the MARK we want to |
1353 | * place |
1348 | * place |
1354 | */ |
1349 | */ |
1355 | for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) |
1350 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1356 | { |
|
|
1357 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->slaying)) |
1351 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->slaying)) |
1358 | break; |
1352 | break; |
1359 | } |
|
|
1360 | |
1353 | |
1361 | /* if we didn't find our own MARK */ |
1354 | /* if we didn't find our own MARK */ |
1362 | if (tmp2 == NULL) |
1355 | if (tmp2 == NULL) |
1363 | { |
1356 | { |
1364 | object *force = get_archetype (FORCE_NAME); |
1357 | object *force = get_archetype (FORCE_NAME); |
1365 | |
1358 | |
|
|
1359 | force->speed = 0; |
|
|
1360 | if (op->stats.food) |
|
|
1361 | { |
1366 | force->speed = 0; |
1362 | force->speed = 0.01; |
|
|
1363 | force->speed_left = -op->stats.food; |
|
|
1364 | } |
|
|
1365 | update_ob_speed (force); |
|
|
1366 | /* put in the lock code */ |
|
|
1367 | force->slaying = op->slaying; |
|
|
1368 | |
|
|
1369 | if (op->lore) |
|
|
1370 | force->lore = op->lore; |
|
|
1371 | |
|
|
1372 | insert_ob_in_ob (force, tmp); |
|
|
1373 | if (op->msg) |
|
|
1374 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg); |
|
|
1375 | |
|
|
1376 | if (op->stats.hp > 0) |
|
|
1377 | { |
|
|
1378 | op->stats.hp--; |
1367 | if (op->stats.food) |
1379 | if (op->stats.hp == 0) |
1368 | { |
1380 | { |
1369 | force->speed = 0.01; |
1381 | /* marker expires--granted mark number limit */ |
1370 | force->speed_left = -op->stats.food; |
1382 | op->destroy (); |
|
|
1383 | return; |
1371 | } |
1384 | } |
1372 | update_ob_speed (force); |
|
|
1373 | /* put in the lock code */ |
|
|
1374 | force->slaying = op->slaying; |
|
|
1375 | |
|
|
1376 | if (op->lore) |
|
|
1377 | force->lore = op->lore; |
|
|
1378 | |
|
|
1379 | insert_ob_in_ob (force, tmp); |
|
|
1380 | if (op->msg) |
|
|
1381 | new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg); |
|
|
1382 | |
|
|
1383 | if (op->stats.hp > 0) |
|
|
1384 | { |
|
|
1385 | op->stats.hp--; |
|
|
1386 | if (op->stats.hp == 0) |
|
|
1387 | { |
|
|
1388 | /* marker expires--granted mark number limit */ |
|
|
1389 | remove_ob (op); |
|
|
1390 | free_object (op); |
|
|
1391 | return; |
|
|
1392 | } |
|
|
1393 | } |
1385 | } |
1394 | } /* if tmp2 == NULL */ |
1386 | } |
1395 | } /* if tmp->type == PLAYER */ |
1387 | } |
1396 | } /* For all objects on this space */ |
|
|
1397 | } |
1388 | } |
1398 | |
1389 | |
1399 | int |
1390 | int |
1400 | process_object (object *op) |
1391 | process_object (object *op) |
1401 | { |
1392 | { |
… | |
… | |
1434 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1425 | if (QUERY_FLAG (op, FLAG_APPLIED)) |
1435 | remove_force (op); |
1426 | remove_force (op); |
1436 | else |
1427 | else |
1437 | { |
1428 | { |
1438 | /* IF necessary, delete the item from the players inventory */ |
1429 | /* IF necessary, delete the item from the players inventory */ |
1439 | object *pl = is_player_inv (op); |
1430 | object *pl = op->in_player (); |
1440 | |
1431 | |
1441 | if (pl) |
1432 | if (pl) |
1442 | esrv_del_item (pl->contr, op->count); |
1433 | esrv_del_item (pl->contr, op->count); |
1443 | |
1434 | |
1444 | remove_ob (op); |
1435 | op->remove (); |
1445 | |
1436 | |
1446 | if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) |
1437 | if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) |
1447 | make_sure_not_seen (op); |
1438 | make_sure_not_seen (op); |
1448 | |
1439 | |
1449 | free_object (op); |
1440 | op->destroy (); |
1450 | } |
1441 | } |
1451 | |
1442 | |
1452 | return 1; |
1443 | return 1; |
1453 | } |
1444 | } |
1454 | |
1445 | |
… | |
… | |
1485 | return 0; |
1476 | return 0; |
1486 | |
1477 | |
1487 | case THROWN_OBJ: |
1478 | case THROWN_OBJ: |
1488 | case ARROW: |
1479 | case ARROW: |
1489 | move_arrow (op); |
1480 | move_arrow (op); |
1490 | return 0; |
|
|
1491 | |
|
|
1492 | case LIGHTNING: /* It now moves twice as fast */ |
|
|
1493 | move_bolt (op); |
|
|
1494 | return 0; |
1481 | return 0; |
1495 | |
1482 | |
1496 | case DOOR: |
1483 | case DOOR: |
1497 | remove_door (op); |
1484 | remove_door (op); |
1498 | return 0; |
1485 | return 0; |