1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game |
3 | |
3 | * |
|
|
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2002 Mark Wedel & Crossfire Development Team |
5 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | |
7 | * |
7 | This program is free software; you can redistribute it and/or modify |
8 | * This program is free software; you can redistribute it and/or modify |
8 | 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 |
9 | the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | (at your option) any later version. |
11 | * (at your option) any later version. |
11 | |
12 | * |
12 | This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
16 | |
17 | * |
17 | You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
18 | along with this program; if not, write to the Free Software |
19 | * along with this program; if not, write to the Free Software |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | |
21 | * |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | */ |
23 | */ |
23 | |
24 | |
24 | /* |
25 | /* |
25 | * Routines that is executed from objects based on their speed have been |
26 | * Routines that is executed from objects based on their speed have been |
26 | * collected in this file. |
27 | * collected in this file. |
27 | */ |
28 | */ |
28 | |
|
|
29 | #include <global.h> |
29 | #include <global.h> |
30 | #include <spells.h> |
30 | #include <spells.h> |
31 | #ifndef __CEXTRACT__ |
|
|
32 | # include <sproto.h> |
31 | #include <sproto.h> |
33 | #endif |
|
|
34 | |
32 | |
35 | /* The following removes doors. The functions check to see if similar |
33 | /* The following removes doors. The functions check to see if similar |
36 | * doors are next to the one that is being removed, and if so, set it |
34 | * doors are next to the one that is being removed, and if so, set it |
37 | * so those will be removed shortly (in a cascade like fashion.) |
35 | * so those will be removed shortly (in a cascade like fashion.) |
38 | */ |
36 | */ |
39 | |
|
|
40 | void |
37 | void |
41 | remove_door (object *op) |
38 | remove_door (object *op) |
42 | { |
39 | { |
43 | int i; |
40 | int i; |
44 | object *tmp; |
41 | object *tmp; |
… | |
… | |
90 | } |
87 | } |
91 | |
88 | |
92 | op->destroy (); |
89 | op->destroy (); |
93 | } |
90 | } |
94 | |
91 | |
95 | /* Will generate a monster according to content |
|
|
96 | * of generator. |
|
|
97 | */ |
|
|
98 | void |
92 | void |
99 | generate_monster_inv (object *gen) |
93 | generate_monster (object *gen) |
100 | { |
94 | { |
101 | int i; |
|
|
102 | object *op, *head = NULL; |
|
|
103 | |
|
|
104 | int qty = 0; |
|
|
105 | |
|
|
106 | /* Code below assumes the generator is on a map, as it tries |
|
|
107 | * to place the monster on the map. So if the generator |
|
|
108 | * isn't on a map, complain and exit. |
|
|
109 | */ |
|
|
110 | if (gen->map == NULL) |
|
|
111 | { |
|
|
112 | //LOG(llevError,"Generator (%s) not on a map?\n", gen->name); |
|
|
113 | return; |
|
|
114 | } |
|
|
115 | /*First count numer of objects in inv */ |
|
|
116 | for (op = gen->inv; op; op = op->below) |
|
|
117 | qty++; |
|
|
118 | if (!qty) |
|
|
119 | { |
|
|
120 | LOG (llevError, "Generator (%s) has no inventory in generate_monster_inv?\n", &gen->name); |
|
|
121 | return; /*No inventory */ |
|
|
122 | } |
|
|
123 | qty = rndm (0, qty - 1); |
|
|
124 | for (op = gen->inv; qty; qty--) |
|
|
125 | op = op->below; |
|
|
126 | i = find_free_spot (op, gen->map, gen->x, gen->y, 1, 9); |
|
|
127 | if (i == -1) |
|
|
128 | return; |
|
|
129 | head = object_create_clone (op); |
|
|
130 | CLEAR_FLAG (head, FLAG_IS_A_TEMPLATE); |
|
|
131 | unflag_inv (head, FLAG_IS_A_TEMPLATE); |
|
|
132 | if (rndm (0, 9)) |
|
|
133 | generate_artifact (head, gen->map->difficulty); |
|
|
134 | insert_ob_in_map_at (head, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]); |
|
|
135 | if (QUERY_FLAG (head, FLAG_FREED)) |
|
|
136 | return; |
|
|
137 | if (head->has_random_items ()) |
|
|
138 | create_treasure (head->randomitems, head, GT_APPLY, gen->map->difficulty, 0); |
|
|
139 | } |
|
|
140 | |
|
|
141 | void |
|
|
142 | generate_monster_arch (object *gen) |
|
|
143 | { |
|
|
144 | int i; |
|
|
145 | object *op, *head = NULL, *prev = NULL; |
|
|
146 | archetype *at = gen->other_arch; |
|
|
147 | |
|
|
148 | if (!gen->other_arch) |
|
|
149 | return; |
|
|
150 | |
|
|
151 | /* Code below assumes the generator is on a map, as it tries |
|
|
152 | * to place the monster on the map. So if the generator |
|
|
153 | * isn't on a map, complain and exit. |
|
|
154 | */ |
|
|
155 | if (!gen->map) |
95 | if (!gen->map) |
156 | return; |
96 | return; |
157 | |
97 | |
158 | i = find_free_spot (&at->clone, gen->map, gen->x, gen->y, 1, 9); |
|
|
159 | if (i == -1) |
|
|
160 | return; |
|
|
161 | |
|
|
162 | while (at) |
|
|
163 | { |
|
|
164 | op = arch_to_object (at); |
|
|
165 | op->x = gen->x + freearr_x[i] + at->clone.x; |
|
|
166 | op->y = gen->y + freearr_y[i] + at->clone.y; |
|
|
167 | |
|
|
168 | if (head) |
|
|
169 | op->head = head, prev->more = op; |
|
|
170 | |
|
|
171 | if (rndm (0, 9)) |
|
|
172 | generate_artifact (op, gen->map->difficulty); |
|
|
173 | |
|
|
174 | insert_ob_in_map (op, gen->map, gen, 0); |
|
|
175 | if (QUERY_FLAG (op, FLAG_FREED)) |
|
|
176 | return; |
|
|
177 | |
|
|
178 | if (op->has_random_items ()) |
|
|
179 | create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty, 0); |
|
|
180 | |
|
|
181 | if (head == NULL) |
|
|
182 | head = op; |
|
|
183 | |
|
|
184 | prev = op; |
|
|
185 | at = at->more; |
|
|
186 | } |
|
|
187 | } |
|
|
188 | |
|
|
189 | void |
|
|
190 | generate_monster (object *gen) |
|
|
191 | { |
|
|
192 | |
|
|
193 | if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1)) |
98 | if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1)) |
194 | return; |
99 | return; |
195 | |
100 | |
|
|
101 | object *op; |
|
|
102 | |
196 | if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN)) |
103 | if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN)) |
197 | generate_monster_inv (gen); |
104 | { |
|
|
105 | // either copy one item form the inventory... |
|
|
106 | if (!gen->inv) |
|
|
107 | return; |
|
|
108 | |
|
|
109 | // first select one item from the inventory |
|
|
110 | int index = 0; |
|
|
111 | for (object *tmp = gen->inv; tmp; tmp = tmp->below) |
|
|
112 | if (!rndm (++index)) |
|
|
113 | op = tmp; |
|
|
114 | |
|
|
115 | op = object_create_clone (op); |
|
|
116 | |
|
|
117 | CLEAR_FLAG (op, FLAG_IS_A_TEMPLATE); |
|
|
118 | unflag_inv (op, FLAG_IS_A_TEMPLATE); |
|
|
119 | } |
198 | else |
120 | else |
199 | generate_monster_arch (gen); |
121 | { |
|
|
122 | // ...or use other_arch |
|
|
123 | if (archetype *at = gen->other_arch) |
|
|
124 | op = arch_to_object (at); |
|
|
125 | else |
|
|
126 | return; |
|
|
127 | } |
200 | |
128 | |
|
|
129 | op->expand_tail (); |
|
|
130 | |
|
|
131 | int i = find_free_spot (op, gen->map, gen->x, gen->y, 1, 9); |
|
|
132 | if (i >= 0) |
|
|
133 | { |
|
|
134 | if (insert_ob_in_map_at (op, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i])) |
|
|
135 | { |
|
|
136 | if (rndm (0, 9)) |
|
|
137 | generate_artifact (op, gen->map->difficulty); |
|
|
138 | |
|
|
139 | if (op->has_random_items ()) |
|
|
140 | create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty); |
|
|
141 | |
|
|
142 | return; |
|
|
143 | } |
|
|
144 | } |
|
|
145 | |
|
|
146 | op->destroy (); |
201 | } |
147 | } |
202 | |
148 | |
203 | void |
149 | void |
204 | remove_force (object *op) |
150 | remove_force (object *op) |
205 | { |
151 | { |
… | |
… | |
248 | return; |
194 | return; |
249 | } |
195 | } |
250 | |
196 | |
251 | if (op->stats.food == 1) |
197 | if (op->stats.food == 1) |
252 | { |
198 | { |
253 | /* need to remove the object before fix_player is called, else fix_player |
199 | /* need to unapply the object before update_stats is called, else fix_player |
254 | * will not do anything. |
200 | * will not do anything. |
255 | */ |
201 | */ |
256 | if (op->env->type == PLAYER) |
202 | if (op->env->type == PLAYER) |
257 | { |
203 | { |
258 | CLEAR_FLAG (op, FLAG_APPLIED); |
204 | CLEAR_FLAG (op, FLAG_APPLIED); |
… | |
… | |
267 | if (op->env->type == PLAYER) |
213 | if (op->env->type == PLAYER) |
268 | { |
214 | { |
269 | op->env->stats.food--; |
215 | op->env->stats.food--; |
270 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick..."); |
216 | new_draw_info (NDI_UNIQUE, 0, op->env, "You feel very sick..."); |
271 | } |
217 | } |
|
|
218 | |
272 | (void) hit_player (op->env, op->stats.dam, op, AT_INTERNAL, 1); |
219 | hit_player (op->env, op->stats.dam, op, AT_INTERNAL, 1); |
273 | } |
220 | } |
274 | |
221 | |
275 | |
222 | |
276 | void |
223 | void |
277 | move_gate (object *op) |
224 | move_gate (object *op) |
… | |
… | |
457 | |
404 | |
458 | if (op->stats.hp) |
405 | if (op->stats.hp) |
459 | { |
406 | { |
460 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
407 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
461 | { |
408 | { |
462 | if (op->slaying && !strcmp (op->slaying, tmp->name)) |
409 | if (op->slaying && op->slaying == tmp->name) |
463 | detected = 1; |
410 | detected = 1; |
|
|
411 | |
464 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->slaying)) |
412 | if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->slaying) |
465 | detected = 1; |
413 | detected = 1; |
466 | } |
414 | } |
467 | } |
415 | } |
|
|
416 | |
468 | if (op->slaying && !strcmp (op->slaying, tmp->name)) |
417 | if (op->slaying && op->slaying == tmp->name) |
469 | { |
|
|
470 | detected = 1; |
418 | detected = 1; |
471 | } |
|
|
472 | else if (tmp->type == SPECIAL_KEY && tmp->slaying == op->slaying) |
419 | else if (tmp->type == SPECIAL_KEY && tmp->slaying == op->slaying) |
473 | detected = 1; |
420 | detected = 1; |
474 | } |
421 | } |
475 | |
422 | |
476 | /* the detector sets the button if detection is found */ |
423 | /* the detector sets the button if detection is found */ |
… | |
… | |
587 | op->destroy (); |
534 | op->destroy (); |
588 | return payload; |
535 | return payload; |
589 | } |
536 | } |
590 | |
537 | |
591 | case ARROW: |
538 | case ARROW: |
592 | if (op->speed >= MIN_ACTIVE_SPEED) |
539 | if (op->has_active_speed ()) |
593 | op = fix_stopped_arrow (op); |
540 | op = fix_stopped_arrow (op); |
594 | return op; |
541 | return op; |
595 | |
542 | |
596 | default: |
543 | default: |
597 | return op; |
544 | return op; |
… | |
… | |
606 | void |
553 | void |
607 | fix_stopped_item (object *op, maptile *map, object *originator) |
554 | fix_stopped_item (object *op, maptile *map, object *originator) |
608 | { |
555 | { |
609 | if (map == NULL) |
556 | if (map == NULL) |
610 | return; |
557 | return; |
|
|
558 | |
611 | if (QUERY_FLAG (op, FLAG_REMOVED)) |
559 | if (QUERY_FLAG (op, FLAG_REMOVED)) |
612 | insert_ob_in_map (op, map, originator, 0); |
560 | insert_ob_in_map (op, map, originator, 0); |
613 | else if (op->type == ARROW) |
561 | else if (op->type == ARROW) |
614 | merge_ob (op, NULL); /* only some arrows actually need this */ |
562 | merge_ob (op, NULL); /* only some arrows actually need this */ |
615 | } |
563 | } |
616 | |
|
|
617 | |
564 | |
618 | object * |
565 | object * |
619 | fix_stopped_arrow (object *op) |
566 | fix_stopped_arrow (object *op) |
620 | { |
567 | { |
621 | if (rndm (0, 99) < op->stats.food) |
568 | if (rndm (0, 99) < op->stats.food) |
… | |
… | |
650 | op->stats.hp = 0; |
597 | op->stats.hp = 0; |
651 | op->stats.grace = 0; |
598 | op->stats.grace = 0; |
652 | op->level = 0; |
599 | op->level = 0; |
653 | op->face = op->arch->clone.face; |
600 | op->face = op->arch->clone.face; |
654 | op->owner = NULL; /* So that stopped arrows will be saved */ |
601 | op->owner = NULL; /* So that stopped arrows will be saved */ |
655 | update_object (op, UP_OBJ_FACE); |
602 | update_object (op, UP_OBJ_CHANGE); |
656 | return op; |
603 | return op; |
657 | } |
604 | } |
658 | |
605 | |
659 | /* stop_arrow() - what to do when a non-living flying object |
606 | /* stop_arrow() - what to do when a non-living flying object |
660 | * has to stop. Sept 96 - I added in thrown object code in |
607 | * has to stop. Sept 96 - I added in thrown object code in |
… | |
… | |
686 | } |
633 | } |
687 | } |
634 | } |
688 | |
635 | |
689 | /* Move an arrow along its course. op is the arrow or thrown object. |
636 | /* Move an arrow along its course. op is the arrow or thrown object. |
690 | */ |
637 | */ |
691 | |
|
|
692 | void |
638 | void |
693 | move_arrow (object *op) |
639 | move_arrow (object *op) |
694 | { |
640 | { |
695 | object *tmp; |
641 | object *tmp; |
696 | sint16 new_x, new_y; |
642 | sint16 new_x, new_y; |
… | |
… | |
767 | * as below. (Note that for living creatures there is a small |
713 | * as below. (Note that for living creatures there is a small |
768 | * chance that reflect_missile fails.) |
714 | * chance that reflect_missile fails.) |
769 | */ |
715 | */ |
770 | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) |
716 | if (QUERY_FLAG (tmp, FLAG_REFL_MISSILE) && (rndm (0, 99)) < (90 - op->level / 10)) |
771 | { |
717 | { |
772 | int number = op->face->number; |
718 | int number = op->face; |
773 | |
719 | |
774 | op->direction = absdir (op->direction + 4); |
720 | op->direction = absdir (op->direction + 4); |
775 | op->state = 0; |
721 | update_turn_face (op); |
776 | |
|
|
777 | if (GET_ANIM_ID (op)) |
|
|
778 | { |
|
|
779 | number += 4; |
|
|
780 | |
|
|
781 | if (number > GET_ANIMATION (op, 8)) |
|
|
782 | number -= 8; |
|
|
783 | |
|
|
784 | op->face = &new_faces[number]; |
|
|
785 | } |
|
|
786 | |
|
|
787 | was_reflected = 1; /* skip normal movement calculations */ |
722 | was_reflected = 1; /* skip normal movement calculations */ |
788 | } |
723 | } |
789 | else |
724 | else |
790 | { |
725 | { |
791 | /* Attack the object. */ |
726 | /* Attack the object. */ |
… | |
… | |
965 | * there is an old multipart teleporter in which the other parts |
900 | * there is an old multipart teleporter in which the other parts |
966 | * have speed, we don't really want to call it twice for the same |
901 | * have speed, we don't really want to call it twice for the same |
967 | * function - in fact, as written below, part N would get called |
902 | * function - in fact, as written below, part N would get called |
968 | * N times without the speed check. |
903 | * N times without the speed check. |
969 | */ |
904 | */ |
970 | if (op->more && FABS (op->more->speed) < MIN_ACTIVE_SPEED) |
905 | if (op->more && !op->more->has_active_speed ()) |
971 | move_teleporter (op->more); |
906 | move_teleporter (op->more); |
972 | |
907 | |
973 | if (op->head) |
908 | if (op->head) |
974 | head = op->head; |
909 | head = op->head; |
975 | |
910 | |
… | |
… | |
986 | if (tmp->type == PLAYER) |
921 | if (tmp->type == PLAYER) |
987 | { |
922 | { |
988 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
923 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) |
989 | return; |
924 | return; |
990 | |
925 | |
991 | enter_exit (tmp, head); |
926 | tmp->enter_exit (head); |
992 | } |
927 | } |
993 | else |
928 | else |
994 | /* Currently only players can transfer maps */ |
929 | /* Currently only players can transfer maps */ |
995 | return; |
930 | return; |
996 | } |
931 | } |
… | |
… | |
1021 | /* This object will teleport someone to a different map |
956 | /* This object will teleport someone to a different map |
1022 | and will also apply changes to the player from its inventory. |
957 | and will also apply changes to the player from its inventory. |
1023 | This was invented for giving classes, but there's no reason it |
958 | This was invented for giving classes, but there's no reason it |
1024 | can't be generalized. |
959 | can't be generalized. |
1025 | */ |
960 | */ |
1026 | |
|
|
1027 | void |
961 | void |
1028 | move_player_changer (object *op) |
962 | move_player_changer (object *op) |
1029 | { |
963 | { |
1030 | object *player; |
964 | object *player; |
1031 | object *walk; |
965 | object *walk; |
1032 | char c; |
|
|
1033 | |
966 | |
1034 | if (!op->above || !EXIT_PATH (op)) |
967 | if (!op->above || !EXIT_PATH (op)) |
1035 | return; |
968 | return; |
1036 | |
969 | |
1037 | /* This isn't all that great - means that the player_mover |
970 | /* This isn't all that great - means that the player_mover |
1038 | * needs to be on top. |
971 | * needs to be on top. |
1039 | */ |
972 | */ |
1040 | if (op->above->type == PLAYER) |
973 | if (op->above->type == PLAYER) |
1041 | { |
974 | { |
1042 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
975 | if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (player))) |
1043 | return; |
976 | return; |
|
|
977 | |
1044 | player = op->above; |
978 | player = op->above; |
1045 | |
979 | |
1046 | for (walk = op->inv; walk != NULL; walk = walk->below) |
980 | for (walk = op->inv; walk; walk = walk->below) |
1047 | apply_changes_to_player (player, walk); |
981 | apply_changes_to_player (player, walk); |
1048 | |
982 | |
1049 | player->update_stats (); |
983 | player->update_stats (); |
1050 | |
984 | |
1051 | esrv_send_inventory (op->above, op->above); |
985 | esrv_send_inventory (op->above, op->above); |
1052 | esrv_update_item (UPD_FACE, op->above, op->above); |
986 | esrv_update_item (UPD_FACE, op->above, op->above); |
1053 | |
987 | |
1054 | /* update players death & WoR home-position */ |
988 | /* update players death & WoR home-position */ |
1055 | sscanf (EXIT_PATH (op), "%c", &c); |
989 | if (*EXIT_PATH (op) == '/') |
1056 | if (c == '/') |
|
|
1057 | { |
990 | { |
1058 | strcpy (player->contr->savebed_map, EXIT_PATH (op)); |
991 | player->contr->savebed_map = EXIT_PATH (op); |
1059 | player->contr->bed_x = EXIT_X (op); |
992 | player->contr->bed_x = EXIT_X (op); |
1060 | player->contr->bed_y = EXIT_Y (op); |
993 | player->contr->bed_y = EXIT_Y (op); |
1061 | } |
994 | } |
1062 | else |
995 | else |
1063 | LOG (llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", &EXIT_PATH (op)); |
996 | LOG (llevDebug, "WARNING: destination '%s' in player_changer must be an absolute path!\n", &EXIT_PATH (op)); |
1064 | |
997 | |
1065 | enter_exit (op->above, op); |
998 | op->above->enter_exit (op); |
1066 | player->contr->save (); |
|
|
1067 | } |
999 | } |
1068 | } |
1000 | } |
1069 | |
1001 | |
1070 | /* firewalls fire other spells. |
1002 | /* firewalls fire other spells. |
1071 | * The direction of the wall is stored in op->stats.sp. |
1003 | * The direction of the wall is stored in op->stats.sp. |
… | |
… | |
1084 | if (!spell || spell->type != SPELL) |
1016 | if (!spell || spell->type != SPELL) |
1085 | spell = &op->other_arch->clone; |
1017 | spell = &op->other_arch->clone; |
1086 | |
1018 | |
1087 | if (!spell) |
1019 | if (!spell) |
1088 | { |
1020 | { |
1089 | LOG (llevError, "move_firewall: no spell specified (%s, %s, %d, %d)\n", &op->name, op->map->name, op->x, op->y); |
1021 | LOG (llevError, "move_firewall: no spell specified (%s, %s, %d, %d)\n", &op->name, &op->map->name, op->x, op->y); |
1090 | return; |
1022 | return; |
1091 | } |
1023 | } |
1092 | |
1024 | |
1093 | cast_spell (op, op, op->stats.sp ? op->stats.sp : rndm (1, 8), spell, NULL); |
1025 | cast_spell (op, op, op->stats.sp ? op->stats.sp : rndm (1, 8), spell, NULL); |
1094 | } |
1026 | } |
… | |
… | |
1132 | nx = op->x + freearr_x[dir]; |
1064 | nx = op->x + freearr_x[dir]; |
1133 | ny = op->y + freearr_y[dir]; |
1065 | ny = op->y + freearr_y[dir]; |
1134 | m = op->map; |
1066 | m = op->map; |
1135 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) |
1067 | if (get_map_flags (m, &m, nx, ny, &nx, &ny) & P_OUT_OF_MAP) |
1136 | { |
1068 | { |
1137 | LOG (llevError, "move_player_mover: Trying to push player off the map! map=%s (%d, %d)\n", m->path, op->x, op->y); |
1069 | LOG (llevError, "move_player_mover: Trying to push player off the map! map=%s (%d, %d)\n", &m->path, op->x, op->y); |
1138 | return; |
1070 | return; |
1139 | } |
1071 | } |
1140 | |
1072 | |
1141 | if (should_director_abort (op, victim)) |
1073 | if (should_director_abort (op, victim)) |
1142 | return; |
1074 | return; |
… | |
… | |
1203 | { |
1135 | { |
1204 | object *tmp; |
1136 | object *tmp; |
1205 | |
1137 | |
1206 | if (!op->other_arch) |
1138 | if (!op->other_arch) |
1207 | { |
1139 | { |
1208 | LOG (llevInfo, "Duplicator with no other_arch! %d %d %s\n", op->x, op->y, op->map ? op->map->path : "nullmap"); |
1140 | LOG (llevInfo, "Duplicator with no other_arch! %d %d %s\n", op->x, op->y, op->map ? &op->map->path : "nullmap"); |
1209 | return; |
1141 | return; |
1210 | } |
1142 | } |
1211 | |
1143 | |
1212 | if (op->above == NULL) |
1144 | if (op->above == NULL) |
1213 | return; |
1145 | return; |
|
|
1146 | |
1214 | for (tmp = op->above; tmp != NULL; tmp = tmp->above) |
1147 | for (tmp = op->above; tmp; tmp = tmp->above) |
1215 | { |
1148 | { |
1216 | if (strcmp (op->other_arch->name, tmp->arch->name) == 0) |
1149 | if (op->other_arch->name == tmp->arch->name) |
1217 | { |
1150 | { |
1218 | if (op->level <= 0) |
1151 | if (op->level <= 0) |
1219 | tmp->destroy (); |
1152 | tmp->destroy (); |
1220 | else |
1153 | else |
1221 | { |
1154 | { |
… | |
… | |
1278 | } |
1211 | } |
1279 | else |
1212 | else |
1280 | { |
1213 | { |
1281 | if (creator->other_arch == NULL) |
1214 | if (creator->other_arch == NULL) |
1282 | { |
1215 | { |
1283 | LOG (llevError, "move_creator: Creator doesn't have other arch set: %s (%s, %d, %d)\n", &creator->name, creator->map->path, |
1216 | LOG (llevError, "move_creator: Creator doesn't have other arch set: %s (%s, %d, %d)\n", |
1284 | creator->x, creator->y); |
1217 | &creator->name, &creator->map->path, creator->x, creator->y); |
1285 | return; |
1218 | return; |
1286 | } |
1219 | } |
1287 | |
1220 | |
1288 | new_ob = object_create_arch (creator->other_arch); |
1221 | new_ob = object_create_arch (creator->other_arch); |
1289 | fix_generated_item (new_ob, creator, 0, 0, GT_MINIMAL); |
1222 | fix_generated_item (new_ob, creator, 0, 0, GT_MINIMAL); |
… | |
… | |
1312 | with a specific code as the slaying field. |
1245 | with a specific code as the slaying field. |
1313 | At that time, it writes the contents of its own message |
1246 | At that time, it writes the contents of its own message |
1314 | field to the player. The marker will decrement hp to |
1247 | field to the player. The marker will decrement hp to |
1315 | 0 and then delete itself every time it grants a mark. |
1248 | 0 and then delete itself every time it grants a mark. |
1316 | unless hp was zero to start with, in which case it is infinite.*/ |
1249 | unless hp was zero to start with, in which case it is infinite.*/ |
1317 | |
|
|
1318 | void |
1250 | void |
1319 | move_marker (object *op) |
1251 | move_marker (object *op) |
1320 | { |
1252 | { |
1321 | if (object *tmp = op->ms ().player ()) |
1253 | if (object *tmp = op->ms ().player ()) |
1322 | { |
1254 | { |
1323 | object *tmp2; |
1255 | object *tmp2; |
1324 | |
1256 | |
1325 | /* remove an old force with a slaying field == op->name */ |
1257 | /* remove an old force with a slaying field == op->name */ |
1326 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1258 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1327 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->name)) |
1259 | if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->name) |
1328 | { |
1260 | { |
1329 | tmp2->destroy (); |
1261 | tmp2->destroy (); |
1330 | break; |
1262 | break; |
1331 | } |
1263 | } |
1332 | |
1264 | |
1333 | /* cycle through his inventory to look for the MARK we want to |
1265 | /* cycle through his inventory to look for the MARK we want to |
1334 | * place |
1266 | * place |
1335 | */ |
1267 | */ |
1336 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1268 | for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) |
1337 | if (tmp2->type == FORCE && tmp2->slaying && !strcmp (tmp2->slaying, op->slaying)) |
1269 | if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->slaying) |
1338 | break; |
1270 | break; |
1339 | |
1271 | |
1340 | /* if we didn't find our own MARK */ |
1272 | /* if we didn't find our own MARK */ |
1341 | if (tmp2 == NULL) |
1273 | if (!tmp2) |
1342 | { |
1274 | { |
1343 | object *force = get_archetype (FORCE_NAME); |
1275 | object *force = get_archetype (FORCE_NAME); |
1344 | |
1276 | |
1345 | if (op->stats.food) |
1277 | if (op->stats.food) |
1346 | { |
1278 | { |