ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/time.C
(Generate patch)

Comparing deliantra/server/server/time.C (file contents):
Revision 1.51 by root, Fri May 18 20:45:37 2007 UTC vs.
Revision 1.66 by root, Mon Aug 27 06:29:18 2007 UTC

1/* 1/*
2 * CrossFire, A Multiplayer game 2 * This file is part of Crossfire TRT, the Roguelike Realtime MORPG.
3 * 3 *
4 * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team 4 * Copyright (©) 2005,2006,2007 Marc Alexander Lehmann / Robin Redeker / the Crossfire TRT team
5 * Copyright (C) 2002 Mark Wedel & Crossfire Development Team 5 * Copyright (©) 2002,2007 Mark Wedel & Crossfire Development Team
6 * Copyright (C) 1992 Frank Tore Johansen 6 * Copyright (©) 1992,2007 Frank Tore Johansen
7 * 7 *
8 * This program is free software; you can redistribute it and/or modify 8 * Crossfire TRT 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
10 * the Free Software Foundation; either version 2 of the License, or 10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version. 11 * (at your option) any later version.
12 * 12 *
13 * 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,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details. 16 * GNU General Public License for more details.
17 * 17 *
18 * 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
19 * along with this program; if not, write to the Free Software 19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * 20 *
22 * The authors can be reached via e-mail at <crossfire@schmorp.de> 21 * The authors can be reached via e-mail to <crossfire@schmorp.de>
23 */ 22 */
24 23
25/* 24/*
26 * Routines that is executed from objects based on their speed have been 25 * Routines that is executed from objects based on their speed have been
27 * collected in this file. 26 * collected in this file.
97 96
98 if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1)) 97 if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1))
99 return; 98 return;
100 99
101 object *op; 100 object *op;
101 int i;
102 102
103 if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN)) 103 if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN))
104 { 104 {
105 // either copy one item form the inventory... 105 // either copy one item from the inventory...
106 if (!gen->inv) 106 if (!gen->inv)
107 return; 107 return;
108 108
109 // first select one item from the inventory 109 // first select one item from the inventory
110 int index = 0; 110 int index = 0;
111 for (object *tmp = gen->inv; tmp; tmp = tmp->below) 111 for (object *tmp = gen->inv; tmp; tmp = tmp->below)
112 if (!rndm (++index)) 112 if (!rndm (++index))
113 op = tmp; 113 op = tmp;
114 114
115 i = find_free_spot (op, gen->map, gen->x, gen->y, 1, 9);
116 if (i < 0)
117 return;
118
115 op = object_create_clone (op); 119 op = object_create_clone (op);
116 120
117 CLEAR_FLAG (op, FLAG_IS_A_TEMPLATE); 121 CLEAR_FLAG (op, FLAG_IS_A_TEMPLATE);
118 unflag_inv (op, FLAG_IS_A_TEMPLATE); 122 unflag_inv (op, FLAG_IS_A_TEMPLATE);
119 } 123 }
124 else if (gen->other_arch)
125 {
126 // ...or use other_arch
127 i = find_free_spot (gen->other_arch, gen->map, gen->x, gen->y, 1, 9);
128 if (i < 0)
129 return;
130
131 op = arch_to_object (gen->other_arch);
132 }
120 else 133 else
121 {
122 // ...or use other_arch
123 if (archetype *at = gen->other_arch)
124 op = arch_to_object (at);
125 else
126 return; 134 return;
127 }
128 135
129 op->expand_tail (); 136 op->expand_tail ();
130 137
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])) 138 if (insert_ob_in_map_at (op, gen->map, gen, 0, gen->x + freearr_x[i], gen->y + freearr_y[i]))
135 { 139 {
136 if (rndm (0, 9)) 140 if (rndm (0, 9))
137 generate_artifact (op, gen->map->difficulty); 141 generate_artifact (op, gen->map->difficulty);
138 142
139 if (op->has_random_items ()) 143 if (op->has_random_items ())
140 create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty); 144 create_treasure (op->randomitems, op, GT_APPLY, gen->map->difficulty);
141 145
142 return; 146 return;
143 }
144 } 147 }
145 148
146 op->destroy (); 149 op->destroy ();
147} 150}
148 151
235 if (op->value) 238 if (op->value)
236 { 239 {
237 if (--op->stats.wc <= 0) 240 if (--op->stats.wc <= 0)
238 { /* Reached bottom, let's stop */ 241 { /* Reached bottom, let's stop */
239 op->stats.wc = 0; 242 op->stats.wc = 0;
240 if (op->arch->clone.speed) 243 if (op->arch->speed)
241 op->value = 0; 244 op->value = 0;
242 else 245 else
243 op->set_speed (0); 246 op->set_speed (0);
244 } 247 }
245 248
265 * objects are above the gate. If so, we finish closing the gate, 268 * objects are above the gate. If so, we finish closing the gate,
266 * otherwise, we fall through to the code below which should lower 269 * otherwise, we fall through to the code below which should lower
267 * the gate slightly. 270 * the gate slightly.
268 */ 271 */
269 272
270 for (tmp = op->above; tmp != NULL; tmp = tmp->above) 273 for (tmp = op->above; tmp; tmp = tmp->above)
271 if (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || QUERY_FLAG (tmp, FLAG_ALIVE)) 274 if (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || QUERY_FLAG (tmp, FLAG_ALIVE))
272 break; 275 break;
273 276
274 if (tmp == NULL) 277 if (!tmp)
275 { 278 {
276 if (op->arch->clone.speed) 279 if (op->arch->speed)
277 op->value = 1; 280 op->value = 1;
278 else 281 else
279 op->set_speed (0); 282 op->set_speed (0);
280 283
281 return; 284 return;
310 if (tmp) 313 if (tmp)
311 { 314 {
312 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 315 if (QUERY_FLAG (tmp, FLAG_ALIVE))
313 { 316 {
314 hit_player (tmp, random_roll (0, op->stats.dam, tmp, PREFER_LOW), op, AT_PHYSICAL, 1); 317 hit_player (tmp, random_roll (0, op->stats.dam, tmp, PREFER_LOW), op, AT_PHYSICAL, 1);
318 op->play_sound (sound_find ("blocked_gate"));
315 319
316 if (tmp->type == PLAYER) 320 if (tmp->type == PLAYER)
317 new_draw_info_format (NDI_UNIQUE, 0, tmp, "You are crushed by the %s!", &op->name); 321 new_draw_info_format (NDI_UNIQUE, 0, tmp, "You are crushed by the %s!", &op->name);
318 } 322 }
319 else
320 /* If the object is not alive, and the object either can 323 /* If the object is not alive, and the object either can
321 * be picked up or the object rolls, move the object 324 * be picked up or the object rolls, move the object
322 * off the gate. 325 * off the gate.
323 */ 326 */
324 if (!QUERY_FLAG (tmp, FLAG_ALIVE) && (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL))) 327 else if (!QUERY_FLAG (tmp, FLAG_ALIVE) && (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL)))
325 { 328 {
326 /* If it has speed, it should move itself, otherwise: */ 329 /* If it has speed, it should move itself, otherwise: */
327 int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9); 330 int i = find_free_spot (tmp, op->map, op->x, op->y, 1, 9);
328 331
329 /* If there is a free spot, move the object someplace */ 332 /* If there is a free spot, move the object someplace */
335 } 338 }
336 } 339 }
337 } 340 }
338 341
339 /* See if there is still anything blocking the gate */ 342 /* See if there is still anything blocking the gate */
340 for (tmp = op->above; tmp != NULL; tmp = tmp->above) 343 for (tmp = op->above; tmp; tmp = tmp->above)
341 if (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || QUERY_FLAG (tmp, FLAG_ALIVE)) 344 if (!QUERY_FLAG (tmp, FLAG_NO_PICK) || QUERY_FLAG (tmp, FLAG_CAN_ROLL) || QUERY_FLAG (tmp, FLAG_ALIVE))
342 break; 345 break;
343 346
344 /* IF there is, start putting the gate down */ 347 /* IF there is, start putting the gate down */
345 if (tmp) 348 if (tmp)
346 {
347 op->stats.food = 1; 349 op->stats.food = 1;
348 }
349 else 350 else
350 { 351 {
351 op->move_block = MOVE_ALL; 352 op->move_block = MOVE_ALL;
353
352 if (!op->arch->clone.stats.ac) 354 if (!op->arch->stats.ac)
353 SET_FLAG (op, FLAG_BLOCKSVIEW); 355 SET_FLAG (op, FLAG_BLOCKSVIEW);
354 update_all_los (op->map, op->x, op->y); 356 update_all_los (op->map, op->x, op->y);
355 } 357 }
356 } /* gate is halfway up */ 358 } /* gate is halfway up */
357 359
370 int v = op->value; 372 int v = op->value;
371 373
372 if (op->stats.sp) 374 if (op->stats.sp)
373 { 375 {
374 move_gate (op); 376 move_gate (op);
377
375 if (op->value != v) /* change direction ? */ 378 if (op->value != v) /* change direction ? */
376 op->stats.sp = 0; 379 op->stats.sp = 0;
377 return; 380 return;
378 } 381 }
382
379 if (--op->stats.hp <= 0) 383 if (--op->stats.hp <= 0)
380 { /* keep gate down */ 384 { /* keep gate down */
381 move_gate (op); 385 move_gate (op);
386
382 if (op->value != v) 387 if (op->value != v)
383 op->set_speed (0); 388 op->set_speed (0);
384 } 389 }
385} 390}
386 391
398 int last = op->value; 403 int last = op->value;
399 int detected; 404 int detected;
400 405
401 detected = 0; 406 detected = 0;
402 407
403 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL && !detected; tmp = tmp->above) 408 for (tmp = op->ms ().bot; tmp && !detected; tmp = tmp->above)
404 { 409 {
405 object *tmp2; 410 object *tmp2;
406 411
407 if (op->stats.hp) 412 if (op->stats.hp)
408 { 413 {
428 if (detected && last == 0) 433 if (detected && last == 0)
429 { 434 {
430 op->value = 1; 435 op->value = 1;
431 push_button (op); 436 push_button (op);
432 } 437 }
438
433 if (!detected && last == 1) 439 if (!detected && last == 1)
434 { 440 {
435 op->value = 0; 441 op->value = 0;
436 push_button (op); 442 push_button (op);
437 } 443 }
441 if (detected && last == 1) 447 if (detected && last == 1)
442 { 448 {
443 op->value = 0; 449 op->value = 0;
444 push_button (op); 450 push_button (op);
445 } 451 }
452
446 if (!detected && last == 0) 453 if (!detected && last == 0)
447 { 454 {
448 op->value = 1; 455 op->value = 1;
449 push_button (op); 456 push_button (op);
450 } 457 }
451 } 458 }
452} 459}
453
454 460
455void 461void
456animate_trigger (object *op) 462animate_trigger (object *op)
457{ 463{
458 if ((unsigned char) ++op->stats.wc >= NUM_ANIMATIONS (op)) 464 if ((unsigned char) ++op->stats.wc >= NUM_ANIMATIONS (op))
490 496
491 SET_ANIMATION (op, op->stats.wc); 497 SET_ANIMATION (op, op->stats.wc);
492 update_object (op, UP_OBJ_FACE); 498 update_object (op, UP_OBJ_FACE);
493 return; 499 return;
494 } 500 }
501
495 /* We're closing */ 502 /* We're closing */
496 op->move_on = 0; 503 op->move_on = 0;
497 504
498 op->stats.wc++; 505 op->stats.wc++;
499 if ((int) op->stats.wc >= NUM_ANIMATIONS (op)) 506 if ((int) op->stats.wc >= NUM_ANIMATIONS (op))
598 op->spellarg = NULL; 605 op->spellarg = NULL;
599 op->stats.sp = 0; 606 op->stats.sp = 0;
600 op->stats.hp = 0; 607 op->stats.hp = 0;
601 op->stats.grace = 0; 608 op->stats.grace = 0;
602 op->level = 0; 609 op->level = 0;
603 op->face = op->arch->clone.face; 610 op->face = op->arch->face;
604 op->owner = NULL; /* So that stopped arrows will be saved */ 611 op->owner = NULL; /* So that stopped arrows will be saved */
605 update_object (op, UP_OBJ_CHANGE); 612 update_object (op, UP_OBJ_CHANGE);
606 return op; 613 return op;
607} 614}
608 615
640/* Move an arrow along its course. op is the arrow or thrown object. 647/* Move an arrow along its course. op is the arrow or thrown object.
641 */ 648 */
642void 649void
643move_arrow (object *op) 650move_arrow (object *op)
644{ 651{
645 object *tmp;
646 sint16 new_x, new_y;
647 int was_reflected, mflags; 652 int was_reflected;
648 maptile *m;
649 653
650 if (op->map == NULL) 654 if (!op->map)
651 { 655 {
652 LOG (llevError, "BUG: Arrow had no map.\n"); 656 LOG (llevError, "BUG: Arrow had no map.\n");
653 op->destroy (); 657 op->destroy ();
654 return; 658 return;
655 } 659 }
685 stop_arrow (op); 689 stop_arrow (op);
686 return; 690 return;
687 } 691 }
688 692
689 /* Calculate target map square */ 693 /* Calculate target map square */
690 new_x = op->x + DIRX (op);
691 new_y = op->y + DIRY (op);
692 was_reflected = 0; 694 was_reflected = 0;
693 695
694 m = op->map; 696 mapxy pos (op); pos.move (op->direction);
695 mflags = get_map_flags (m, &m, new_x, new_y, &new_x, &new_y);
696 697
697 if (mflags & P_OUT_OF_MAP) 698 if (!pos.normalise ())
698 { 699 {
699 stop_arrow (op); 700 stop_arrow (op);
700 return; 701 return;
701 } 702 }
702 703
703 /* only need to look for living creatures if this flag is set */ 704 /* only need to look for living creatures if this flag is set */
704 if (mflags & P_IS_ALIVE) 705 if (pos->flags () & P_IS_ALIVE)
705 { 706 {
706 for (tmp = GET_MAP_OB (m, new_x, new_y); tmp != NULL; tmp = tmp->above) 707 object *tmp;
708
709 for (tmp = pos->bot; tmp; tmp = tmp->above)
707 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 710 if (QUERY_FLAG (tmp, FLAG_ALIVE))
708 break; 711 break;
709 712
710 /* Not really fair, but don't let monsters hit themselves with 713 /* Not really fair, but don't let monsters hit themselves with
711 * their own arrow - this can be because they fire it then 714 * their own arrow - this can be because they fire it then
734 return; 737 return;
735 } 738 }
736 } /* if this is not hitting its owner */ 739 } /* if this is not hitting its owner */
737 } /* if there is something alive on this space */ 740 } /* if there is something alive on this space */
738 741
739 if (OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m, new_x, new_y))) 742 if (OB_TYPE_MOVE_BLOCK (op, pos->move_block))
740 { 743 {
741 int retry = 0; 744 int retry = 0;
742 745
743 /* if the object doesn't reflect, stop the arrow from moving 746 /* if the object doesn't reflect, stop the arrow from moving
744 * note that this code will now catch cases where a monster is 747 * note that this code will now catch cases where a monster is
757 if (op->direction & 1) 760 if (op->direction & 1)
758 { 761 {
759 op->direction = absdir (op->direction + 4); 762 op->direction = absdir (op->direction + 4);
760 retry = 1; 763 retry = 1;
761 } 764 }
765
762 /* There were two blocks with identical code - 766 /* There were two blocks with identical code -
763 * use this retry here to make this one block 767 * use this retry here to make this one block
764 * that did the same thing. 768 * that did the same thing.
765 */ 769 */
766 while (retry < 2) 770 while (retry < 2)
767 { 771 {
768 int left, right, mflags;
769 maptile *m1;
770 sint16 x1, y1;
771
772 retry++; 772 retry++;
773 773
774 /* Need to check for P_OUT_OF_MAP: if the arrow is tavelling 774 /* Need to check for P_OUT_OF_MAP: if the arrow is travelling
775 * over a corner in a tiled map, it is possible that 775 * over a corner in a tiled map, it is possible that
776 * op->direction is within an adjacent map but either 776 * op->direction is within an adjacent map but either
777 * op->direction-1 or op->direction+1 does not exist. 777 * op->direction-1 or op->direction+1 does not exist.
778 */ 778 */
779 mflags = get_map_flags (op->map, &m1, op->x + freearr_x[absdir (op->direction - 1)], 779 mapxy pos1 (pos); pos1.move (absdir (op->direction - 1));
780 op->y + freearr_y[absdir (op->direction - 1)], &x1, &y1); 780 bool left = pos1.normalise () && OB_TYPE_MOVE_BLOCK (op, pos1->move_block);
781 left = (mflags & P_OUT_OF_MAP) ? 0 : OB_TYPE_MOVE_BLOCK (op, (GET_MAP_MOVE_BLOCK (m1, x1, y1)));
782 781
783 mflags = get_map_flags (op->map, &m1, op->x + freearr_x[absdir (op->direction + 1)], 782 mapxy pos2 (pos); pos2.move (absdir (op->direction + 1));
784 op->y + freearr_y[absdir (op->direction + 1)], &x1, &y1); 783 bool right = pos2.normalise () && OB_TYPE_MOVE_BLOCK (op, pos2->move_block);
785 right = (mflags & P_OUT_OF_MAP) ? 0 : OB_TYPE_MOVE_BLOCK (op, (GET_MAP_MOVE_BLOCK (m1, x1, y1)));
786 784
787 if (left == right) 785 if (left == right)
788 op->direction = absdir (op->direction + 4); 786 op->direction = absdir (op->direction + 4);
789 else if (left) 787 else if (left)
790 op->direction = absdir (op->direction + 2); 788 op->direction = absdir (op->direction + 2);
791 else if (right) 789 else if (right)
792 op->direction = absdir (op->direction - 2); 790 op->direction = absdir (op->direction - 2);
793 791
794 mflags = get_map_flags (op->map, &m1, op->x + DIRX (op), op->y + DIRY (op), &x1, &y1);
795
796 /* If this space is not out of the map and not blocked, valid space - 792 /* If this space is not out of the map and not blocked, valid space -
797 * don't need to retry again. 793 * don't need to retry again.
798 */ 794 */
799 if (!(mflags & P_OUT_OF_MAP) && !OB_TYPE_MOVE_BLOCK (op, GET_MAP_MOVE_BLOCK (m1, x1, y1))) 795 mapxy pos3 (pos); pos3.move (op->direction);
796 if (pos3.normalise () && !OB_TYPE_MOVE_BLOCK (op, pos3->move_block))
800 break; 797 break;
801
802 } 798 }
799
803 /* Couldn't find a direction to move the arrow to - just 800 /* Couldn't find a direction to move the arrow to - just
804 * top it from moving. 801 * stop it from moving.
805 */ 802 */
806 if (retry == 2) 803 if (retry == 2)
807 { 804 {
808 stop_arrow (op); 805 stop_arrow (op);
809 return; 806 return;
810 } 807 }
808
811 /* update object image for new facing */ 809 /* update object image for new facing */
812 /* many thrown objects *don't* have more than one face */ 810 /* many thrown objects *don't* have more than one face */
813 if (GET_ANIM_ID (op)) 811 if (GET_ANIM_ID (op))
814 SET_ANIMATION (op, op->direction); 812 SET_ANIMATION (op, op->direction);
815 } /* object is reflected */ 813 } /* object is reflected */
816 } /* object ran into a wall */ 814 } /* object ran into a wall */
817 815
818 /* Move the arrow. */
819 op->remove ();
820 op->x = new_x;
821 op->y = new_y;
822
823 /* decrease the speed as it flies. 0.05 means a standard bow will shoot 816 /* decrease the speed as it flies. 0.05 means a standard bow will shoot
824 * about 17 squares. Tune as needed. 817 * about 17 squares. Tune as needed.
825 */ 818 */
826 op->speed -= 0.05; 819 op->speed -= 0.05;
827 insert_ob_in_map (op, m, op, 0); 820
821 /* Move the arrow. */
822 op->move_to (pos);
828} 823}
829 824
830/* This routine doesnt seem to work for "inanimate" objects that 825/* This routine doesnt seem to work for "inanimate" objects that
831 * are being carried, ie a held torch leaps from your hands!. 826 * are being carried, ie a held torch leaps from your hands!.
832 * Modified this routine to allow held objects. b.t. */ 827 * Modified this routine to allow held objects. b.t. */
833
834void 828void
835change_object (object *op) 829change_object (object *op)
836{ /* Doesn`t handle linked objs yet */ 830{ /* Doesn`t handle linked objs yet */
837 int i, j; 831 int i, j;
838 832
910 move_teleporter (op->more); 904 move_teleporter (op->more);
911 905
912 if (op->head) 906 if (op->head)
913 head = op->head; 907 head = op->head;
914 908
915 for (tmp = op->above; tmp != NULL; tmp = tmp->above) 909 for (tmp = op->above; tmp; tmp = tmp->above)
916 if (!QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 910 if (!QUERY_FLAG (tmp, FLAG_IS_FLOOR))
917 break; 911 break;
918 912
919 /* If nothing above us to move, nothing to do */ 913 /* If nothing above us to move, nothing to do */
920 if (!tmp || QUERY_FLAG (tmp, FLAG_WIZPASS)) 914 if (!tmp || QUERY_FLAG (tmp, FLAG_WIZPASS))
953 if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp))) 947 if (INVOKE_OBJECT (TRIGGER, op, ARG_OBJECT (tmp)))
954 return; 948 return;
955 teleport (head, TELEPORTER, tmp); 949 teleport (head, TELEPORTER, tmp);
956 } 950 }
957} 951}
958
959 952
960/* This object will teleport someone to a different map 953/* This object will teleport someone to a different map
961 and will also apply changes to the player from its inventory. 954 and will also apply changes to the player from its inventory.
962 This was invented for giving classes, but there's no reason it 955 This was invented for giving classes, but there's no reason it
963 can't be generalized. 956 can't be generalized.
1016 return; /* dm has created a firewall in his inventory */ 1009 return; /* dm has created a firewall in his inventory */
1017 1010
1018 spell = op->inv; 1011 spell = op->inv;
1019 1012
1020 if (!spell || spell->type != SPELL) 1013 if (!spell || spell->type != SPELL)
1021 spell = &op->other_arch->clone; 1014 spell = op->other_arch;
1022 1015
1023 if (!spell) 1016 if (!spell)
1024 { 1017 {
1025 LOG (llevError, "move_firewall: no spell specified (%s, %s, %d, %d)\n", &op->name, &op->map->name, op->x, op->y); 1018 LOG (llevError, "move_firewall: no spell specified (%s, %s, %d, %d)\n", &op->name, &op->map->name, op->x, op->y);
1026 return; 1019 return;
1094 * is cleared, otherwise the player will get stuck in 1087 * is cleared, otherwise the player will get stuck in
1095 * place. This can happen if the player used a spell to 1088 * place. This can happen if the player used a spell to
1096 * get to this space. 1089 * get to this space.
1097 */ 1090 */
1098 victim->contr->fire_on = 0; 1091 victim->contr->fire_on = 0;
1099 victim->speed_left = 0.f; 1092 victim->speed_left = 1.f;
1100 move_player (victim, dir); 1093 move_player (victim, dir);
1101 } 1094 }
1102 else 1095 else
1103 return; 1096 return;
1104 } 1097 }
1137 if (op->above == NULL) 1130 if (op->above == NULL)
1138 return; 1131 return;
1139 1132
1140 for (tmp = op->above; tmp; tmp = tmp->above) 1133 for (tmp = op->above; tmp; tmp = tmp->above)
1141 { 1134 {
1142 if (op->other_arch->name == tmp->arch->name) 1135 if (op->other_arch->archname == tmp->arch->archname)
1143 { 1136 {
1144 if (op->level <= 0) 1137 if (op->level <= 0)
1145 tmp->destroy (); 1138 tmp->destroy ();
1146 else 1139 else
1147 { 1140 {
1169 * has to make sure that there is in fact space for the object. 1162 * has to make sure that there is in fact space for the object.
1170 * It should really do this for small objects also, but there is 1163 * It should really do this for small objects also, but there is
1171 * more concern with large objects, most notably a part being placed 1164 * more concern with large objects, most notably a part being placed
1172 * outside of the map which would cause the server to crash 1165 * outside of the map which would cause the server to crash
1173*/ 1166*/
1174
1175void 1167void
1176move_creator (object *creator) 1168move_creator (object *creator)
1177{ 1169{
1178 object *new_ob; 1170 object *new_ob;
1179 1171
1219 if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y)) 1211 if (new_ob->arch->more && ob_blocked (new_ob, creator->map, creator->x, creator->y))
1220 { 1212 {
1221 new_ob->destroy (); 1213 new_ob->destroy ();
1222 return; 1214 return;
1223 } 1215 }
1216
1217 // for now lets try to identify everything generated here, it mostly
1218 // happens automated, so this will at least fix many identify-experience holes
1219 SET_FLAG (new_ob, FLAG_IDENTIFIED);
1224 1220
1225 insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y); 1221 insert_ob_in_map_at (new_ob, creator->map, creator, 0, creator->x, creator->y);
1226 if (QUERY_FLAG (new_ob, FLAG_FREED)) 1222 if (QUERY_FLAG (new_ob, FLAG_FREED))
1227 return; 1223 return;
1228 1224
1243void 1239void
1244move_marker (object *op) 1240move_marker (object *op)
1245{ 1241{
1246 if (object *tmp = op->ms ().player ()) 1242 if (object *tmp = op->ms ().player ())
1247 { 1243 {
1248 object *tmp2;
1249
1250 /* remove an old force with a slaying field == op->name */ 1244 /* remove an old force with a slaying field == op->name */
1251 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below) 1245 if (object *force = tmp->force_find (op->name))
1252 if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->name) 1246 force->destroy ();
1247
1248 if (!tmp->force_find (op->slaying))
1253 { 1249 {
1254 tmp2->destroy (); 1250 tmp->force_add (op->slaying, op->stats.food);
1255 break;
1256 }
1257 1251
1258 /* cycle through his inventory to look for the MARK we want to
1259 * place
1260 */
1261 for (tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below)
1262 if (tmp2->type == FORCE && tmp2->slaying && tmp2->slaying == op->slaying)
1263 break;
1264
1265 /* if we didn't find our own MARK */
1266 if (!tmp2)
1267 {
1268 object *force = get_archetype (FORCE_NAME);
1269
1270 if (op->stats.food)
1271 {
1272 force->set_speed (0.01);
1273 force->speed_left = -op->stats.food;
1274 }
1275 else
1276 force->set_speed (0);
1277
1278 /* put in the lock code */
1279 force->slaying = op->slaying;
1280
1281 if (op->lore)
1282 force->lore = op->lore;
1283
1284 insert_ob_in_ob (force, tmp);
1285 if (op->msg) 1252 if (op->msg)
1286 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg); 1253 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, tmp, op->msg);
1287 1254
1288 if (op->stats.hp > 0) 1255 if (op->stats.hp > 0)
1289 { 1256 {
1290 op->stats.hp--; 1257 op->stats.hp--;
1258
1291 if (op->stats.hp == 0) 1259 if (op->stats.hp == 0)
1292 { 1260 {
1293 /* marker expires--granted mark number limit */ 1261 /* marker expires--granted mark number limit */
1294 op->destroy (); 1262 op->destroy ();
1295 return; 1263 return;
1300} 1268}
1301 1269
1302void 1270void
1303process_object (object *op) 1271process_object (object *op)
1304{ 1272{
1305 if (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)) 1273 if (expect_false (QUERY_FLAG (op, FLAG_IS_A_TEMPLATE)))
1306 return; 1274 return;
1307 1275
1308 if (INVOKE_OBJECT (TICK, op)) 1276 if (expect_false (INVOKE_OBJECT (TICK, op)))
1309 return; 1277 return;
1310 1278
1311 if (QUERY_FLAG (op, FLAG_MONSTER)) 1279 if (QUERY_FLAG (op, FLAG_MONSTER))
1312 if (move_monster (op) || QUERY_FLAG (op, FLAG_FREED)) 1280 if (move_monster (op) || QUERY_FLAG (op, FLAG_FREED))
1313 return; 1281 return;
1318 1286
1319 if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE)) 1287 if (QUERY_FLAG (op, FLAG_SEE_ANYWHERE))
1320 make_sure_seen (op); 1288 make_sure_seen (op);
1321 } 1289 }
1322 1290
1291 if (expect_false (
1323 if (op->flag [FLAG_GENERATOR] 1292 op->flag [FLAG_GENERATOR]
1324 || op->flag [FLAG_CHANGING] 1293 || op->flag [FLAG_CHANGING]
1325 || op->flag [FLAG_IS_USED_UP]) 1294 || op->flag [FLAG_IS_USED_UP]
1295 ))
1326 { 1296 {
1327 if (QUERY_FLAG (op, FLAG_CHANGING) && !op->state) 1297 if (QUERY_FLAG (op, FLAG_CHANGING) && !op->state)
1328 { 1298 {
1329 change_object (op); 1299 change_object (op);
1330 return; 1300 return;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines