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

Comparing deliantra/server/server/spell_effect.C (file contents):
Revision 1.17 by root, Tue Dec 12 21:39:57 2006 UTC vs.
Revision 1.28 by root, Sat Dec 30 10:16:11 2006 UTC

37void 37void
38cast_magic_storm (object *op, object *tmp, int lvl) 38cast_magic_storm (object *op, object *tmp, int lvl)
39{ 39{
40 if (!tmp) 40 if (!tmp)
41 return; /* error */ 41 return; /* error */
42
42 tmp->level = op->level; 43 tmp->level = op->level;
43 tmp->x = op->x;
44 tmp->y = op->y;
45 tmp->range += lvl / 5; /* increase the area of destruction */ 44 tmp->range += lvl / 5; /* increase the area of destruction */
46 tmp->duration += lvl / 5; 45 tmp->duration += lvl / 5;
47 46
48 /* Put a cap on duration for this - if the player fails in their 47 /* Put a cap on duration for this - if the player fails in their
49 * apartment, don't want it to go on so long that it kills them 48 * apartment, don't want it to go on so long that it kills them
50 * multiple times. Also, damge already increases with level, 49 * multiple times. Also, damge already increases with level,
51 * so don't really need to increase the duration as much either. 50 * so don't really need to increase the duration as much either.
52 */ 51 */
53 if (tmp->duration >= 40) 52 if (tmp->duration >= 40)
54 tmp->duration = 40; 53 tmp->duration = 40;
54
55 tmp->stats.dam = lvl; /* nasty recoils! */ 55 tmp->stats.dam = lvl; /* nasty recoils! */
56 tmp->stats.maxhp = tmp->count; /* tract single parent */ 56 tmp->stats.maxhp = tmp->count; /* tract single parent */
57 insert_ob_in_map (tmp, op->map, op, 0);
58 57
58 tmp->insert_at (op, op);
59} 59}
60
61 60
62int 61int
63recharge (object *op, object *caster, object *spell_ob) 62recharge (object *op, object *caster, object *spell_ob)
64{ 63{
65 object *wand, *tmp; 64 object *wand, *tmp;
77 play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE); 76 play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE);
78 esrv_del_item (op->contr, wand->count); 77 esrv_del_item (op->contr, wand->count);
79 wand->destroy (); 78 wand->destroy ();
80 tmp = get_archetype ("fireball"); 79 tmp = get_archetype ("fireball");
81 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; 80 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10;
81
82 if (!tmp->stats.dam) 82 if (!tmp->stats.dam)
83 tmp->stats.dam = 1; 83 tmp->stats.dam = 1;
84
84 tmp->stats.hp = tmp->stats.dam / 2; 85 tmp->stats.hp = tmp->stats.dam / 2;
86
85 if (tmp->stats.hp < 2) 87 if (tmp->stats.hp < 2)
86 tmp->stats.hp = 2; 88 tmp->stats.hp = 2;
87 tmp->x = op->x; 89
88 tmp->y = op->y; 90 tmp->insert_at (op);
89 insert_ob_in_map (tmp, op->map, NULL, 0);
90 return 1; 91 return 1;
91 } 92 }
92 93
93 ncharges = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)); 94 ncharges = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob));
95
94 if (wand->inv && wand->inv->level) 96 if (wand->inv && wand->inv->level)
95 ncharges /= wand->inv->level; 97 ncharges /= wand->inv->level;
96 else 98 else
97 { 99 {
98 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", query_name (wand)); 100 new_draw_info_format (NDI_UNIQUE, 0, op, "Your %s is broken.", query_name (wand));
99 return 0; 101 return 0;
100 } 102 }
103
101 if (!ncharges) 104 if (!ncharges)
102 ncharges = 1; 105 ncharges = 1;
103 106
104 wand->stats.food += ncharges; 107 wand->stats.food += ncharges;
105 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s glows with power.", query_name (wand)); 108 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s glows with power.", query_name (wand));
109
106 if (wand->arch && QUERY_FLAG (&wand->arch->clone, FLAG_ANIMATE)) 110 if (wand->arch && QUERY_FLAG (&wand->arch->clone, FLAG_ANIMATE))
107 { 111 {
108 SET_FLAG (wand, FLAG_ANIMATE); 112 SET_FLAG (wand, FLAG_ANIMATE);
109 wand->speed = wand->arch->clone.speed; 113 wand->set_speed (wand->arch->clone.speed);
110 update_ob_speed (wand);
111 } 114 }
115
112 return 1; 116 return 1;
113} 117}
114 118
115/* Create a missile (nonmagic - magic +4). Will either create bolts or arrows 119/* Create a missile (nonmagic - magic +4). Will either create bolts or arrows
116 * based on whether a crossbow or bow is equiped. If neither, it defaults to 120 * based on whether a crossbow or bow is equiped. If neither, it defaults to
302 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic."); 306 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic.");
303 return 0; 307 return 0;
304 } 308 }
305 if (mflags & P_IS_ALIVE) 309 if (mflags & P_IS_ALIVE)
306 { 310 {
307 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 311 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
308 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) 312 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER)))
309 { 313 {
310 new_draw_info (NDI_UNIQUE, 0, op, "You detect something."); 314 new_draw_info (NDI_UNIQUE, 0, op, "You detect something.");
311 if (tmp->head != NULL) 315 if (tmp->head != NULL)
312 tmp = tmp->head; 316 tmp = tmp->head;
440 444
441 if (mflags & P_OUT_OF_MAP) 445 if (mflags & P_OUT_OF_MAP)
442 continue; 446 continue;
443 447
444 // earth to dust tears down everything that can be teared down 448 // earth to dust tears down everything that can be teared down
445 for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) 449 for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next)
446 { 450 {
447 next = tmp->above; 451 next = tmp->above;
448 if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN)) 452 if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN))
449 hit_player (tmp, 9998, op, AT_PHYSICAL, 0); 453 hit_player (tmp, 9998, op, AT_PHYSICAL, 0);
450 } 454 }
463 467
464 if (op != NULL && op->map) 468 if (op != NULL && op->map)
465 if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST))) 469 if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST)))
466 new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you."); 470 new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you.");
467 else 471 else
468 enter_exit (op, wor); 472 op->enter_exit (wor);
469 473
470 wor->destroy (); 474 wor->destroy ();
471} 475}
472 476
473/* Word of recall causes the player to return 'home'. 477/* Word of recall causes the player to return 'home'.
502 506
503 /* value of speed really doesn't make much difference, as long as it is 507 /* value of speed really doesn't make much difference, as long as it is
504 * positive. Lower value may be useful so that the problem doesn't 508 * positive. Lower value may be useful so that the problem doesn't
505 * do anything really odd if it say a -1000 or something. 509 * do anything really odd if it say a -1000 or something.
506 */ 510 */
507 dummy->speed = 0.002; 511 dummy->set_speed (0.002);
508 update_ob_speed (dummy);
509 dummy->speed_left = -dummy->speed * time; 512 dummy->speed_left = -dummy->speed * time;
510 dummy->type = SPELL_EFFECT; 513 dummy->type = SPELL_EFFECT;
511 dummy->subtype = SP_WORD_OF_RECALL; 514 dummy->subtype = SP_WORD_OF_RECALL;
512 515
513 /* If we could take advantage of enter_player_savebed() here, it would be 516 /* If we could take advantage of enter_player_savebed() here, it would be
555 } 558 }
556 return cast_spell (op, caster, dir, newspell, NULL); 559 return cast_spell (op, caster, dir, newspell, NULL);
557 } 560 }
558 return 1; 561 return 1;
559} 562}
560
561 563
562int 564int
563perceive_self (object *op) 565perceive_self (object *op)
564{ 566{
565 char *cp = describe_item (op, op), buf[MAX_BUF]; 567 char *cp = describe_item (op, op), buf[MAX_BUF];
637cast_create_town_portal (object *op, object *caster, object *spell, int dir) 639cast_create_town_portal (object *op, object *caster, object *spell, int dir)
638{ 640{
639 object *dummy, *force, *old_force, *tmp; 641 object *dummy, *force, *old_force, *tmp;
640 archetype *perm_portal; 642 archetype *perm_portal;
641 char portal_name[1024], portal_message[1024]; 643 char portal_name[1024], portal_message[1024];
642 sint16 exitx, exity;
643 maptile *exitmap; 644 maptile *exitmap;
644 int op_level; 645 int op_level;
645
646 646
647 /* Check to see if the map the player is currently on is a per player unique 647 /* Check to see if the map the player is currently on is a per player unique
648 * map. This can be determined in that per player unique maps have the 648 * map. This can be determined in that per player unique maps have the
649 * full pathname listed. 649 * full pathname listed.
650 */ 650 */
662 { 662 {
663 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 663 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
664 LOG (llevError, "object::create failed (force in cast_create_town_portal for %s!\n", &op->name); 664 LOG (llevError, "object::create failed (force in cast_create_town_portal for %s!\n", &op->name);
665 return 0; 665 return 0;
666 } 666 }
667
667 force = check_inv_recursive (op, dummy); 668 force = check_inv_recursive (op, dummy);
668 669
669 if (force == NULL) 670 if (force == NULL)
670 { 671 {
671 /* Here we know there is no destination marked up. 672 /* Here we know there is no destination marked up.
705 { 706 {
706 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 707 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
707 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); 708 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
708 return 0; 709 return 0;
709 } 710 }
711
710 perm_portal = archetype::find (spell->slaying); 712 perm_portal = archetype::find (spell->slaying);
711 713
712 /* To kill a town portal, we go trough the player's inventory, 714 /* To kill a town portal, we go trough the player's inventory,
713 * for each marked portal in player's inventory, 715 * for each marked portal in player's inventory,
714 * -We try load the associated map (if impossible, consider the portal destructed) 716 * -We try load the associated map (if impossible, consider the portal destructed)
716 * If it has the good name, we destruct it. 718 * If it has the good name, we destruct it.
717 * -We destruct the force indicating that portal. 719 * -We destruct the force indicating that portal.
718 */ 720 */
719 while ((old_force = check_inv_recursive (op, dummy))) 721 while ((old_force = check_inv_recursive (op, dummy)))
720 { 722 {
721 exitx = EXIT_X (old_force); 723 exitmap = maptile::find_map (old_force->race, op->map);
722 exity = EXIT_Y (old_force);
723 LOG (llevDebug, "Trying to kill a portal in %s (%d,%d)\n", &old_force->race, exitx, exity);
724
725 if (!strncmp (old_force->race, settings.localdir, strlen (settings.localdir)))
726 exitmap = ready_map_name (old_force->race, MAP_PLAYER_UNIQUE);
727 else
728 exitmap = ready_map_name (old_force->race, 0);
729 724
730 if (exitmap) 725 if (exitmap)
731 { 726 {
727 int exitx = EXIT_X (old_force);
728 int exity = EXIT_Y (old_force);
729
732 tmp = present_arch (perm_portal, exitmap, exitx, exity); 730 tmp = present_arch (perm_portal, exitmap, exitx, exity);
733 while (tmp) 731 while (tmp)
734 { 732 {
735 if (tmp->name == old_force->name) 733 if (tmp->name == old_force->name)
736 { 734 {
741 tmp = tmp->above; 739 tmp = tmp->above;
742 } 740 }
743 } 741 }
744 742
745 old_force->destroy (); 743 old_force->destroy ();
746 LOG (llevDebug, "\n");
747 } 744 }
748 745
749 dummy->destroy (); 746 dummy->destroy ();
750 747
751 /* Creating the portals. 748 /* Creating the portals.
757 * 'force' is the destination of the town portal, which we got 754 * 'force' is the destination of the town portal, which we got
758 * from the players inventory above. 755 * from the players inventory above.
759 */ 756 */
760 757
761 /* Ensure exit map is loaded */ 758 /* Ensure exit map is loaded */
762 if (!strncmp (force->name, settings.localdir, strlen (settings.localdir)))
763 exitmap = ready_map_name (force->name, MAP_PLAYER_UNIQUE);
764 else
765 exitmap = ready_map_name (force->name, 0); 759 exitmap = maptile::find_map (force->name, 0);
766 760
767 /* If we were unable to load (ex. random map deleted), warn player */ 761 /* If we were unable to load (ex. random map deleted), warn player */
768 if (exitmap == NULL) 762 if (!exitmap)
769 { 763 {
770 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); 764 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?");
771 force->destroy (); 765 force->destroy ();
772 return 1; 766 return 1;
773 } 767 }
788 782
789 /* Create a portal in front of player 783 /* Create a portal in front of player
790 * dummy contain the portal and 784 * dummy contain the portal and
791 * force contain the track to kill it later 785 * force contain the track to kill it later
792 */ 786 */
793
794 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name); 787 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name);
795 dummy = get_archetype (spell->slaying); /*The portal */ 788 dummy = get_archetype (spell->slaying); /*The portal */
796 if (dummy == NULL) 789 if (dummy == NULL)
797 { 790 {
798 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 791 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
799 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); 792 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
800 return 0; 793 return 0;
801 } 794 }
795
802 EXIT_PATH (dummy) = force->name; 796 EXIT_PATH (dummy) = force->name;
803 EXIT_X (dummy) = EXIT_X (force); 797 EXIT_X (dummy) = EXIT_X (force);
804 EXIT_Y (dummy) = EXIT_Y (force); 798 EXIT_Y (dummy) = EXIT_Y (force);
805 dummy->name = dummy->name_pl = portal_name; 799 dummy->name = dummy->name_pl = portal_name;
806 dummy->msg = portal_message; 800 dummy->msg = portal_message;
816 { 810 {
817 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 811 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
818 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); 812 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
819 return 0; 813 return 0;
820 } 814 }
815
821 tmp->race = op->map->path; 816 tmp->race = op->map->path;
822 tmp->name = portal_name; 817 tmp->name = portal_name;
823 EXIT_X (tmp) = dummy->x; 818 EXIT_X (tmp) = dummy->x;
824 EXIT_Y (tmp) = dummy->y; 819 EXIT_Y (tmp) = dummy->y;
825 insert_ob_in_ob (tmp, op); 820 op->insert (tmp);
826 821
827 /* Create a portal in the destination map 822 /* Create a portal in the destination map
828 * dummy contain the portal and 823 * dummy contain the portal and
829 * force the track to kill it later 824 * force the track to kill it later
830 * the 'force' variable still contains the 'reminder' of 825 * the 'force' variable still contains the 'reminder' of
831 * where this portal goes to. 826 * where this portal goes to.
832 */ 827 */
833 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); 828 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &op->map->path);
834 dummy = get_archetype (spell->slaying); /*The portal */ 829 dummy = get_archetype (spell->slaying); /*The portal */
835 if (dummy == NULL) 830 if (dummy == NULL)
836 { 831 {
837 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 832 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
838 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); 833 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
839 return 0; 834 return 0;
840 } 835 }
836
841 EXIT_PATH (dummy) = op->map->path; 837 EXIT_PATH (dummy) = op->map->path;
842 EXIT_X (dummy) = op->x; 838 EXIT_X (dummy) = op->x;
843 EXIT_Y (dummy) = op->y; 839 EXIT_Y (dummy) = op->y;
844 dummy->name = dummy->name_pl = portal_name; 840 dummy->name = dummy->name_pl = portal_name;
845 dummy->msg = portal_message; 841 dummy->msg = portal_message;
846 dummy->x = EXIT_X (force);
847 dummy->y = EXIT_Y (force);
848 dummy->race = op->name; /*Save the owner of the portal */ 842 dummy->race = op->name; /*Save the owner of the portal */
849 insert_ob_in_map (dummy, exitmap, op, 0); 843 exitmap->insert (dummy, EXIT_X (force), EXIT_Y (force), op);
850 844
851 /* Now we create another town portal marker that 845 /* Now we create another town portal marker that
852 * points back to the one we just made 846 * points back to the one we just made
853 */ 847 */
854 tmp = get_archetype (spell->race); 848 tmp = get_archetype (spell->race);
856 { 850 {
857 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 851 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
858 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name); 852 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
859 return 0; 853 return 0;
860 } 854 }
855
861 tmp->race = force->name; 856 tmp->race = force->name;
862 tmp->name = portal_name; 857 tmp->name = portal_name;
863 EXIT_X (tmp) = dummy->x; 858 EXIT_X (tmp) = dummy->x;
864 EXIT_Y (tmp) = dummy->y; 859 EXIT_Y (tmp) = dummy->y;
865 insert_ob_in_ob (tmp, op); 860 insert_ob_in_ob (tmp, op);
870 force->destroy (); 865 force->destroy ();
871 866
872 return 1; 867 return 1;
873} 868}
874 869
875
876/* This creates magic walls. Really, it can create most any object, 870/* This creates magic walls. Really, it can create most any object,
877 * within some reason. 871 * within some reason.
878 */ 872 */
879
880int 873int
881magic_wall (object *op, object *caster, int dir, object *spell_ob) 874magic_wall (object *op, object *caster, int dir, object *spell_ob)
882{ 875{
883 object *tmp, *tmp2; 876 object *tmp;
884 int i, posblocked, negblocked, maxrange; 877 int i, posblocked, negblocked, maxrange;
885 sint16 x, y; 878 sint16 x, y;
886 maptile *m; 879 maptile *m;
887 const char *name; 880 const char *name;
888 archetype *at; 881 archetype *at;
896 else 889 else
897 { 890 {
898 x = op->x + freearr_x[dir]; 891 x = op->x + freearr_x[dir];
899 y = op->y + freearr_y[dir]; 892 y = op->y + freearr_y[dir];
900 } 893 }
894
901 m = op->map; 895 m = op->map;
902 896
903 if ((spell_ob->move_block || x != op->x || y != op->y) && 897 if ((spell_ob->move_block || x != op->x || y != op->y) &&
904 (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) || 898 (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) ||
905 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block))) 899 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block)))
906 { 900 {
907 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 901 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
908 return 0; 902 return 0;
909 } 903 }
904
910 if (spell_ob->other_arch) 905 if (spell_ob->other_arch)
911 {
912 tmp = arch_to_object (spell_ob->other_arch); 906 tmp = arch_to_object (spell_ob->other_arch);
913 }
914 else if (spell_ob->race) 907 else if (spell_ob->race)
915 { 908 {
916 char buf1[MAX_BUF]; 909 char buf1[MAX_BUF];
917 910
918 sprintf (buf1, spell_ob->race, dir); 911 sprintf (buf1, spell_ob->race, dir);
921 { 914 {
922 LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1); 915 LOG (llevError, "summon_wall: Unable to find archetype %s\n", buf1);
923 new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken."); 916 new_draw_info (NDI_UNIQUE, 0, op, "This spell is broken.");
924 return 0; 917 return 0;
925 } 918 }
919
926 tmp = arch_to_object (at); 920 tmp = arch_to_object (at);
927 } 921 }
928 else 922 else
929 { 923 {
930 LOG (llevError, "magic_wall: spell %s lacks other_arch\n", &spell_ob->name); 924 LOG (llevError, "magic_wall: spell %s lacks other_arch\n", &spell_ob->name);
940 } 934 }
941 else if (QUERY_FLAG (tmp, FLAG_ALIVE)) 935 else if (QUERY_FLAG (tmp, FLAG_ALIVE))
942 { 936 {
943 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 937 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
944 tmp->stats.maxhp = tmp->stats.hp; 938 tmp->stats.maxhp = tmp->stats.hp;
945 set_owner (tmp, op);
946 set_spell_skill (op, caster, spell_ob, tmp);
947 } 939 }
940
948 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) 941 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP))
949 { 942 {
950 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 943 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
951 SET_FLAG (tmp, FLAG_IS_USED_UP); 944 SET_FLAG (tmp, FLAG_IS_USED_UP);
952 } 945 }
946
953 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN)) 947 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN))
954 { 948 {
955 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 949 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
956 tmp->stats.maxhp = tmp->stats.hp; 950 tmp->stats.maxhp = tmp->stats.hp;
957 SET_FLAG (tmp, FLAG_TEAR_DOWN); 951 SET_FLAG (tmp, FLAG_TEAR_DOWN);
958 SET_FLAG (tmp, FLAG_ALIVE); 952 SET_FLAG (tmp, FLAG_ALIVE);
959 } 953 }
960 954
961 /* This can't really hurt - if the object doesn't kill anything, 955 /* This can't really hurt - if the object doesn't kill anything,
962 * these fields just won't be used. 956 * these fields just won't be used. Do not set the owner for
957 * earthwalls, though, so they survive restarts.
963 */ 958 */
964 set_owner (tmp, op); 959 if (tmp->type != EARTHWALL) //TODO
960 tmp->set_owner (op);
961
965 set_spell_skill (op, caster, spell_ob, tmp); 962 set_spell_skill (op, caster, spell_ob, tmp);
966 tmp->x = x;
967 tmp->y = y;
968 tmp->level = caster_level (caster, spell_ob) / 2; 963 tmp->level = caster_level (caster, spell_ob) / 2;
969 964
970 name = tmp->name; 965 name = tmp->name;
971 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) 966 if (!(tmp = m->insert (tmp, x, y, op)))
972 { 967 {
973 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name); 968 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name);
974 return 0; 969 return 0;
975 } 970 }
971
976 /* If this is a spellcasting wall, need to insert the spell object */ 972 /* If this is a spellcasting wall, need to insert the spell object */
977 if (tmp->other_arch && tmp->other_arch->clone.type == SPELL) 973 if (tmp->other_arch && tmp->other_arch->clone.type == SPELL)
978 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp); 974 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp);
979 975
980 /* This code causes the wall to extend some distance in 976 /* This code causes the wall to extend some distance in
998 m = tmp->map; 994 m = tmp->map;
999 995
1000 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 996 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) &&
1001 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) 997 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked)
1002 { 998 {
1003 tmp2 = object::create (); 999 object *tmp2 = tmp->clone ();
1004 tmp->copy_to (tmp2); 1000 m->insert (tmp2, x, y, op);
1005 tmp2->x = x; 1001
1006 tmp2->y = y;
1007 insert_ob_in_map (tmp2, m, op, 0);
1008 /* If this is a spellcasting wall, need to insert the spell object */ 1002 /* If this is a spellcasting wall, need to insert the spell object */
1009 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) 1003 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
1010 insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); 1004 tmp2->insert (arch_to_object (tmp2->other_arch));
1011 1005
1012 } 1006 }
1013 else 1007 else
1014 posblocked = 1; 1008 posblocked = 1;
1015 1009
1018 m = tmp->map; 1012 m = tmp->map;
1019 1013
1020 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 1014 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) &&
1021 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) 1015 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked)
1022 { 1016 {
1023 tmp2 = object::create (); 1017 object *tmp2 = tmp->clone ();
1024 tmp->copy_to (tmp2); 1018 m->insert (tmp2, x, y, op);
1025 tmp2->x = x; 1019
1026 tmp2->y = y;
1027 insert_ob_in_map (tmp2, m, op, 0);
1028 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) 1020 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
1029 insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); 1021 tmp2->insert (arch_to_object (tmp2->other_arch));
1030 } 1022 }
1031 else 1023 else
1032 negblocked = 1; 1024 negblocked = 1;
1033 } 1025 }
1034 1026
1083 { 1075 {
1084 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the spell.\n"); 1076 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks the magic of the spell.\n");
1085 op->contr->count = 0; 1077 op->contr->count = 0;
1086 return 0; 1078 return 0;
1087 } 1079 }
1080
1088 op->contr->count = 0; 1081 op->contr->count = 0;
1089 1082
1090 /* Remove code that puts player on random space on maps. IMO, 1083 /* Remove code that puts player on random space on maps. IMO,
1091 * a lot of maps probably have areas the player should not get to, 1084 * a lot of maps probably have areas the player should not get to,
1092 * but may not be marked as NO_MAGIC (as they may be bounded 1085 * but may not be marked as NO_MAGIC (as they may be bounded
1141 return 0; 1134 return 0;
1142 } 1135 }
1143 } 1136 }
1144 1137
1145 /* Actually move the player now */ 1138 /* Actually move the player now */
1146 op->remove (); 1139 if (!(op = op->map->insert (op, op->x + freearr_x[dir] * dist, op->y + freearr_y[dir] * dist, op)))
1147 op->x += freearr_x[dir] * dist;
1148 op->y += freearr_y[dir] * dist;
1149 if ((op = insert_ob_in_map (op, op->map, op, 0)) == NULL)
1150 return 1; 1140 return 1;
1151 1141
1152 op->speed_left = -FABS (op->speed) * 5; /* Freeze them for a short while */ 1142 op->speed_left = -FABS (op->speed) * 5; /* Freeze them for a short while */
1153 return 1; 1143 return 1;
1154} 1144}
1298}; 1288};
1299 1289
1300int 1290int
1301cast_change_ability (object *op, object *caster, object *spell_ob, int dir, int silent) 1291cast_change_ability (object *op, object *caster, object *spell_ob, int dir, int silent)
1302{ 1292{
1303 object *tmp, *tmp2 = NULL;
1304 object *force = NULL; 1293 object *force = NULL;
1305 int i; 1294 int i;
1306 1295
1307 /* if dir = 99 op defaults to tmp, eat_special_food() requires this. */ 1296 /* if dir = 99 op defaults to tmp, eat_special_food() requires this. */
1308 if (dir != 0) 1297 object *tmp = dir
1309 {
1310 tmp = find_target_for_friendly_spell (op, dir); 1298 ? find_target_for_friendly_spell (op, dir)
1311 } 1299 : op;
1312 else
1313 {
1314 tmp = op;
1315 }
1316 1300
1317 if (tmp == NULL) 1301 if (!tmp)
1318 return 0; 1302 return 0;
1319 1303
1320 /* If we've already got a force of this type, don't add a new one. */ 1304 /* If we've already got a force of this type, don't add a new one. */
1321 for (tmp2 = tmp->inv; tmp2 != NULL; tmp2 = tmp2->below) 1305 for (object *tmp2 = tmp->inv; tmp2; tmp2 = tmp2->below)
1322 { 1306 {
1323 if (tmp2->type == FORCE && tmp2->subtype == FORCE_CHANGE_ABILITY) 1307 if (tmp2->type == FORCE && tmp2->subtype == FORCE_CHANGE_ABILITY)
1324 { 1308 {
1325 if (tmp2->name == spell_ob->name) 1309 if (tmp2->name == spell_ob->name)
1326 { 1310 {
1428 force->stats.ac = spell_ob->stats.ac; 1412 force->stats.ac = spell_ob->stats.ac;
1429 force->attacktype = spell_ob->attacktype; 1413 force->attacktype = spell_ob->attacktype;
1430 1414
1431 insert_ob_in_ob (force, tmp); 1415 insert_ob_in_ob (force, tmp);
1432 change_abil (tmp, force); /* Mostly to display any messages */ 1416 change_abil (tmp, force); /* Mostly to display any messages */
1433 fix_player (tmp); 1417 tmp->update_stats ();
1434 return 1; 1418 return 1;
1435} 1419}
1436 1420
1437/* This used to be part of cast_change_ability, but it really didn't make 1421/* This used to be part of cast_change_ability, but it really didn't make
1438 * a lot of sense, since most of the values it derives are from the god 1422 * a lot of sense, since most of the values it derives are from the god
1537 force->stats.wc = spell_ob->stats.wc; 1521 force->stats.wc = spell_ob->stats.wc;
1538 force->stats.ac = spell_ob->stats.ac; 1522 force->stats.ac = spell_ob->stats.ac;
1539 1523
1540 change_abil (tmp, force); /* Mostly to display any messages */ 1524 change_abil (tmp, force); /* Mostly to display any messages */
1541 insert_ob_in_ob (force, tmp); 1525 insert_ob_in_ob (force, tmp);
1542 fix_player (tmp); 1526 tmp->update_stats ();
1543 return 1; 1527 return 1;
1544} 1528}
1545 1529
1546 1530
1547 1531
1634 if (x == op->x && y == op->y && op->map == m) 1618 if (x == op->x && y == op->y && op->map == m)
1635 flag = INS_BELOW_ORIGINATOR; 1619 flag = INS_BELOW_ORIGINATOR;
1636 1620
1637 if (small_nuggets) 1621 if (small_nuggets)
1638 { 1622 {
1639 tmp = object::create (); 1623 tmp = small->clone ();
1640 small->copy_to (tmp);
1641 tmp->nrof = small_nuggets; 1624 tmp->nrof = small_nuggets;
1642 tmp->x = x;
1643 tmp->y = y;
1644 insert_ob_in_map (tmp, m, op, flag); 1625 m->insert (tmp, x, y, op, flag);
1645 } 1626 }
1627
1646 if (large_nuggets) 1628 if (large_nuggets)
1647 { 1629 {
1648 tmp = object::create (); 1630 tmp = large->clone ();
1649 large->copy_to (tmp);
1650 tmp->nrof = large_nuggets; 1631 tmp->nrof = large_nuggets;
1651 tmp->x = x;
1652 tmp->y = y;
1653 insert_ob_in_map (tmp, m, op, flag); 1632 m->insert (tmp, x, y, op, flag);
1654 } 1633 }
1655} 1634}
1656 1635
1657int 1636int
1658alchemy (object *op, object *caster, object *spell_ob) 1637alchemy (object *op, object *caster, object *spell_ob)
1695 continue; 1674 continue;
1696 1675
1697 small_nuggets = 0; 1676 small_nuggets = 0;
1698 large_nuggets = 0; 1677 large_nuggets = 0;
1699 1678
1700 for (tmp = get_map_ob (mp, nx, ny); tmp != NULL; tmp = next) 1679 for (tmp = GET_MAP_OB (mp, nx, ny); tmp != NULL; tmp = next)
1701 { 1680 {
1702 next = tmp->above; 1681 next = tmp->above;
1703 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) && 1682 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) &&
1704 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 1683 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON))
1705 { 1684 {
1739 large->destroy (); 1718 large->destroy ();
1740 small->destroy (); 1719 small->destroy ();
1741 /* reset this so that if player standing on a big pile of stuff, 1720 /* reset this so that if player standing on a big pile of stuff,
1742 * it is redrawn properly. 1721 * it is redrawn properly.
1743 */ 1722 */
1744 op->contr->socket.look_position = 0; 1723 op->contr->ns->look_position = 0;
1745 return 1; 1724 return 1;
1746} 1725}
1747 1726
1748 1727
1749/* This function removes the cursed/damned status on equipped 1728/* This function removes the cursed/damned status on equipped
1758 for (tmp = op->inv; tmp; tmp = tmp->below) 1737 for (tmp = op->inv; tmp; tmp = tmp->below)
1759 if (QUERY_FLAG (tmp, FLAG_APPLIED) && 1738 if (QUERY_FLAG (tmp, FLAG_APPLIED) &&
1760 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || 1739 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) ||
1761 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) 1740 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED))))
1762 { 1741 {
1763
1764 was_one++; 1742 was_one++;
1765 if (tmp->level <= caster_level (caster, spell)) 1743 if (tmp->level <= caster_level (caster, spell))
1766 { 1744 {
1767 success++; 1745 success++;
1768 if (QUERY_FLAG (spell, FLAG_DAMNED)) 1746 if (QUERY_FLAG (spell, FLAG_DAMNED))
1788 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); 1766 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse.");
1789 else 1767 else
1790 new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); 1768 new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items.");
1791 } 1769 }
1792 } 1770 }
1771
1793 return success; 1772 return success;
1794} 1773}
1795 1774
1796/* Identifies objects in the players inventory/on the ground */ 1775/* Identifies objects in the players inventory/on the ground */
1797 1776
1804 num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1783 num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1805 1784
1806 if (num_ident < 1) 1785 if (num_ident < 1)
1807 num_ident = 1; 1786 num_ident = 1;
1808 1787
1809
1810 for (tmp = op->inv; tmp; tmp = tmp->below) 1788 for (tmp = op->inv; tmp; tmp = tmp->below)
1811 { 1789 {
1812 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1790 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1813 { 1791 {
1814 identify (tmp); 1792 identify (tmp);
1793
1815 if (op->type == PLAYER) 1794 if (op->type == PLAYER)
1816 { 1795 {
1817 new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op)); 1796 new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op));
1797
1818 if (tmp->msg) 1798 if (tmp->msg)
1819 { 1799 {
1820 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); 1800 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1821 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 1801 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1822 } 1802 }
1823 } 1803 }
1804
1824 num_ident--; 1805 num_ident--;
1825 success = 1; 1806 success = 1;
1826 if (!num_ident) 1807 if (!num_ident)
1827 break; 1808 break;
1828 } 1809 }
1829 } 1810 }
1811
1830 /* If all the power of the spell has been used up, don't go and identify 1812 /* If all the power of the spell has been used up, don't go and identify
1831 * stuff on the floor. Only identify stuff on the floor if the spell 1813 * stuff on the floor. Only identify stuff on the floor if the spell
1832 * was not fully used. 1814 * was not fully used.
1833 */ 1815 */
1834 if (num_ident) 1816 if (num_ident)
1835 { 1817 {
1836 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1818 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
1837 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1819 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1838 { 1820 {
1839
1840 identify (tmp); 1821 identify (tmp);
1822
1841 if (op->type == PLAYER) 1823 if (op->type == PLAYER)
1842 { 1824 {
1843 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op)); 1825 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op));
1826
1844 if (tmp->msg) 1827 if (tmp->msg)
1845 { 1828 {
1846 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); 1829 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1847 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 1830 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1848 } 1831 }
1832
1849 esrv_send_item (op, tmp); 1833 esrv_send_item (op, tmp);
1850 } 1834 }
1835
1851 num_ident--; 1836 num_ident--;
1852 success = 1; 1837 success = 1;
1853 if (!num_ident) 1838 if (!num_ident)
1854 break; 1839 break;
1855 } 1840 }
1856 } 1841 }
1842
1857 if (!success) 1843 if (!success)
1858 new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); 1844 new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified.");
1859 else 1845 else
1860 {
1861 spell_effect (spell, op->x, op->y, op->map, op); 1846 spell_effect (spell, op->x, op->y, op->map, op);
1862 } 1847
1863 return success; 1848 return success;
1864} 1849}
1865
1866 1850
1867int 1851int
1868cast_detection (object *op, object *caster, object *spell, object *skill) 1852cast_detection (object *op, object *caster, object *spell, object *skill)
1869{ 1853{
1870 object *tmp, *last, *god, *detect; 1854 object *tmp, *last, *god, *detect;
1883 skill = caster; 1867 skill = caster;
1884 1868
1885 for (x = op->x - range; x <= op->x + range; x++) 1869 for (x = op->x - range; x <= op->x + range; x++)
1886 for (y = op->y - range; y <= op->y + range; y++) 1870 for (y = op->y - range; y <= op->y + range; y++)
1887 { 1871 {
1888
1889 m = op->map; 1872 m = op->map;
1890 mflags = get_map_flags (m, &m, x, y, &nx, &ny); 1873 mflags = get_map_flags (m, &m, x, y, &nx, &ny);
1891 if (mflags & P_OUT_OF_MAP) 1874 if (mflags & P_OUT_OF_MAP)
1892 continue; 1875 continue;
1893 1876
1895 * floor. But this is not true for show invisible. 1878 * floor. But this is not true for show invisible.
1896 * Basically, we just go and find the top object and work 1879 * Basically, we just go and find the top object and work
1897 * down - that is easier than working up. 1880 * down - that is easier than working up.
1898 */ 1881 */
1899 1882
1900 for (last = NULL, tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) 1883 for (last = NULL, tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above)
1901 last = tmp; 1884 last = tmp;
1885
1902 /* Shouldn't happen, but if there are no objects on a space, this 1886 /* Shouldn't happen, but if there are no objects on a space, this
1903 * would happen. 1887 * would happen.
1904 */ 1888 */
1905 if (!last) 1889 if (!last)
1906 continue; 1890 continue;
1908 done_one = 0; 1892 done_one = 0;
1909 floor = 0; 1893 floor = 0;
1910 detect = NULL; 1894 detect = NULL;
1911 for (tmp = last; tmp; tmp = tmp->below) 1895 for (tmp = last; tmp; tmp = tmp->below)
1912 { 1896 {
1913
1914 /* show invisible */ 1897 /* show invisible */
1915 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && 1898 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) &&
1916 /* Might there be other objects that we can make visibile? */ 1899 /* Might there be other objects that we can make visible? */
1917 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || 1900 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) ||
1918 (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || 1901 (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) ||
1919 tmp->type == CF_HANDLE || 1902 tmp->type == CF_HANDLE ||
1920 tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || 1903 tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE ||
1921 tmp->type == BUTTON || tmp->type == TELEPORTER || 1904 tmp->type == BUTTON || tmp->type == TELEPORTER ||
1928 { 1911 {
1929 tmp->invisible = 0; 1912 tmp->invisible = 0;
1930 done_one = 1; 1913 done_one = 1;
1931 } 1914 }
1932 } 1915 }
1916
1933 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1917 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1934 floor = 1; 1918 floor = 1;
1935 1919
1936 /* All detections below this point don't descend beneath the floor, 1920 /* All detections below this point don't descend beneath the floor,
1937 * so just continue on. We could be clever and look at the type of 1921 * so just continue on. We could be clever and look at the type of
1990 */ 1974 */
1991 if (done_one) 1975 if (done_one)
1992 { 1976 {
1993 object *detect_ob = arch_to_object (spell->other_arch); 1977 object *detect_ob = arch_to_object (spell->other_arch);
1994 1978
1995 detect_ob->x = nx;
1996 detect_ob->y = ny;
1997 /* if this is set, we want to copy the face */ 1979 /* if this is set, we want to copy the face */
1998 if (done_one == 2 && detect) 1980 if (done_one == 2 && detect)
1999 { 1981 {
2000 detect_ob->face = detect->face; 1982 detect_ob->face = detect->face;
2001 detect_ob->animation_id = detect->animation_id; 1983 detect_ob->animation_id = detect->animation_id;
2003 detect_ob->last_anim = 0; 1985 detect_ob->last_anim = 0;
2004 /* by default, the detect_ob is already animated */ 1986 /* by default, the detect_ob is already animated */
2005 if (!QUERY_FLAG (detect, FLAG_ANIMATE)) 1987 if (!QUERY_FLAG (detect, FLAG_ANIMATE))
2006 CLEAR_FLAG (detect_ob, FLAG_ANIMATE); 1988 CLEAR_FLAG (detect_ob, FLAG_ANIMATE);
2007 } 1989 }
1990
2008 insert_ob_in_map (detect_ob, m, op, 0); 1991 m->insert (detect_ob, nx, ny, op);
2009 } 1992 }
2010 } /* for processing the surrounding spaces */ 1993 } /* for processing the surrounding spaces */
2011 1994
2012 1995
2013 /* Now process objects in the players inventory if detect curse or magic */ 1996 /* Now process objects in the players inventory if detect curse or magic */
2062 2045
2063 /* Explodes a fireball centered at player */ 2046 /* Explodes a fireball centered at player */
2064 tmp = get_archetype (EXPLODING_FIREBALL); 2047 tmp = get_archetype (EXPLODING_FIREBALL);
2065 tmp->dam_modifier = random_roll (1, caster_level, victim, PREFER_LOW) / 5 + 1; 2048 tmp->dam_modifier = random_roll (1, caster_level, victim, PREFER_LOW) / 5 + 1;
2066 tmp->stats.maxhp = random_roll (1, caster_level, victim, PREFER_LOW) / 10 + 2; 2049 tmp->stats.maxhp = random_roll (1, caster_level, victim, PREFER_LOW) / 10 + 2;
2067 tmp->x = victim->x; 2050
2068 tmp->y = victim->y; 2051 tmp->insert_at (victim);
2069 insert_ob_in_map (tmp, victim->map, NULL, 0);
2070 victim->stats.sp = 2 * victim->stats.maxsp; 2052 victim->stats.sp = 2 * victim->stats.maxsp;
2071 } 2053 }
2072 else if (victim->stats.sp >= victim->stats.maxsp * 1.88) 2054 else if (victim->stats.sp >= victim->stats.maxsp * 1.88)
2073 {
2074 new_draw_info (NDI_UNIQUE, NDI_ORANGE, victim, "You feel like your head is going to explode."); 2055 new_draw_info (NDI_UNIQUE, NDI_ORANGE, victim, "You feel like your head is going to explode.");
2075 }
2076 else if (victim->stats.sp >= victim->stats.maxsp * 1.66) 2056 else if (victim->stats.sp >= victim->stats.maxsp * 1.66)
2077 {
2078 new_draw_info (NDI_UNIQUE, 0, victim, "You get a splitting headache!"); 2057 new_draw_info (NDI_UNIQUE, 0, victim, "You get a splitting headache!");
2079 }
2080 else if (victim->stats.sp >= victim->stats.maxsp * 1.5) 2058 else if (victim->stats.sp >= victim->stats.maxsp * 1.5)
2081 { 2059 {
2082 new_draw_info (NDI_UNIQUE, 0, victim, "Chaos fills your world."); 2060 new_draw_info (NDI_UNIQUE, 0, victim, "Chaos fills your world.");
2083 confuse_player (victim, victim, 99); 2061 confuse_player (victim, victim, 99);
2084 } 2062 }
2085 else if (victim->stats.sp >= victim->stats.maxsp * 1.25) 2063 else if (victim->stats.sp >= victim->stats.maxsp * 1.25)
2086 {
2087 new_draw_info (NDI_UNIQUE, 0, victim, "You start hearing voices."); 2064 new_draw_info (NDI_UNIQUE, 0, victim, "You start hearing voices.");
2088 }
2089} 2065}
2090 2066
2091/* cast_transfer 2067/* cast_transfer
2092 * This spell transfers sp from the player to another person. 2068 * This spell transfers sp from the player to another person.
2093 * We let the target go above their normal maximum SP. 2069 * We let the target go above their normal maximum SP.
2107 2083
2108 mflags = get_map_flags (m, &m, x, y, &x, &y); 2084 mflags = get_map_flags (m, &m, x, y, &x, &y);
2109 2085
2110 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 2086 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
2111 { 2087 {
2112 for (plyr = get_map_ob (m, x, y); plyr != NULL; plyr = plyr->above) 2088 for (plyr = GET_MAP_OB (m, x, y); plyr != NULL; plyr = plyr->above)
2113 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 2089 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE))
2114 break; 2090 break;
2115 } 2091 }
2116 2092
2117 2093
2118 /* If we did not find a player in the specified direction, transfer 2094 /* If we did not find a player in the specified direction, transfer
2119 * to anyone on top of us. This is used for the rune of transference mostly. 2095 * to anyone on top of us. This is used for the rune of transference mostly.
2120 */ 2096 */
2121 if (plyr == NULL) 2097 if (plyr == NULL)
2122 for (plyr = get_map_ob (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above) 2098 for (plyr = GET_MAP_OB (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above)
2123 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 2099 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE))
2124 break; 2100 break;
2125 2101
2126 if (!plyr) 2102 if (!plyr)
2127 { 2103 {
2182 m = op->map; 2158 m = op->map;
2183 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 2159 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
2184 if (mflags & P_OUT_OF_MAP) 2160 if (mflags & P_OUT_OF_MAP)
2185 return; 2161 return;
2186 2162
2187 for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) 2163 for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next)
2188 { 2164 {
2189 next = tmp->above; 2165 next = tmp->above;
2190 2166
2191 /* Need to look at the head object - otherwise, if tmp 2167 /* Need to look at the head object - otherwise, if tmp
2192 * points to a monster, we don't have all the necessary 2168 * points to a monster, we don't have all the necessary
2371 CLEAR_FLAG (tmp, FLAG_MONSTER); 2347 CLEAR_FLAG (tmp, FLAG_MONSTER);
2372 SET_FLAG (tmp, FLAG_FRIENDLY); 2348 SET_FLAG (tmp, FLAG_FRIENDLY);
2373 tmp->stats.exp = 0; 2349 tmp->stats.exp = 0;
2374 add_friendly_object (tmp); 2350 add_friendly_object (tmp);
2375 tmp->type = GOLEM; 2351 tmp->type = GOLEM;
2376 set_owner (tmp, op); 2352 tmp->set_owner (op);
2377 set_spell_skill (op, caster, spell, tmp); 2353 set_spell_skill (op, caster, spell, tmp);
2378 op->contr->ranges[range_golem] = tmp; 2354 op->contr->ranges[range_golem] = tmp;
2379 op->contr->shoottype = range_golem; 2355 op->contr->shoottype = range_golem;
2380 2356
2381 /* Give the weapon to the golem now. A bit of a hack to check the 2357 /* Give the weapon to the golem now. A bit of a hack to check the
2390 * so instead, just set it as equipped (otherwise, we need to update 2366 * so instead, just set it as equipped (otherwise, we need to update
2391 * body_info, skills, etc) 2367 * body_info, skills, etc)
2392 */ 2368 */
2393 SET_FLAG (tmp, FLAG_USE_WEAPON); 2369 SET_FLAG (tmp, FLAG_USE_WEAPON);
2394 SET_FLAG (weapon, FLAG_APPLIED); 2370 SET_FLAG (weapon, FLAG_APPLIED);
2395 fix_player (tmp); 2371 tmp->update_stats ();
2396 2372
2397 /* There used to be 'odd' code that basically seemed to take the absolute 2373 /* There used to be 'odd' code that basically seemed to take the absolute
2398 * value of the weapon->magic an use that. IMO, that doesn't make sense - 2374 * value of the weapon->magic an use that. IMO, that doesn't make sense -
2399 * if you're using a crappy weapon, it shouldn't be as good. 2375 * if you're using a crappy weapon, it shouldn't be as good.
2400 */ 2376 */
2452 if (a > 14) 2428 if (a > 14)
2453 a = 14; 2429 a = 14;
2454 tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a)); 2430 tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a));
2455 2431
2456 /* Determine golem's speed */ 2432 /* Determine golem's speed */
2457 tmp->speed = 0.4 + 0.1 * SP_level_range_adjust (caster, spell); 2433 tmp->set_speed (min (3.33, 0.4 + 0.1 * SP_level_range_adjust (caster, spell)));
2458
2459 if (tmp->speed > 3.33)
2460 tmp->speed = 3.33;
2461 2434
2462 if (!spell->race) 2435 if (!spell->race)
2463 { 2436 {
2464 sprintf (buf, "animated %s", &weapon->name); 2437 sprintf (buf, "animated %s", &weapon->name);
2465 tmp->name = buf; 2438 tmp->name = buf;
2467 tmp->face = weapon->face; 2440 tmp->face = weapon->face;
2468 tmp->animation_id = weapon->animation_id; 2441 tmp->animation_id = weapon->animation_id;
2469 tmp->anim_speed = weapon->anim_speed; 2442 tmp->anim_speed = weapon->anim_speed;
2470 tmp->last_anim = weapon->last_anim; 2443 tmp->last_anim = weapon->last_anim;
2471 tmp->state = weapon->state; 2444 tmp->state = weapon->state;
2472 if (QUERY_FLAG (weapon, FLAG_ANIMATE)) 2445 tmp->flag [FLAG_ANIMATE] = weapon->flag [FLAG_ANIMATE];
2473 {
2474 SET_FLAG (tmp, FLAG_ANIMATE);
2475 }
2476 else
2477 {
2478 CLEAR_FLAG (tmp, FLAG_ANIMATE);
2479 }
2480 update_ob_speed (tmp);
2481 } 2446 }
2482 2447
2483 /* make experience increase in proportion to the strength of the summoned creature. */ 2448 /* make experience increase in proportion to the strength of the summoned creature. */
2484 tmp->stats.exp *= 1 + (MAX (spell->stats.maxgrace, spell->stats.sp) / caster_level (caster, spell)); 2449 tmp->stats.exp *= 1 + (MAX (spell->stats.maxgrace, spell->stats.sp) / caster_level (caster, spell));
2485 2450
2486 tmp->speed_left = -1; 2451 tmp->speed_left = -1;
2487 tmp->x = x;
2488 tmp->y = y;
2489 tmp->direction = dir; 2452 tmp->direction = dir;
2490 insert_ob_in_map (tmp, m, op, 0); 2453
2454 m->insert (tmp, x, y, op);
2491 return 1; 2455 return 1;
2492} 2456}
2493 2457
2494/* cast_daylight() - changes the map darkness level *lower* */ 2458/* cast_daylight() - changes the map darkness level *lower* */
2495 2459
2503 int success; 2467 int success;
2504 2468
2505 if (!op->map) 2469 if (!op->map)
2506 return 0; /* shouldnt happen */ 2470 return 0; /* shouldnt happen */
2507 2471
2508 success = change_map_light (op->map, spell->stats.dam); 2472 success = op->map->change_map_light (spell->stats.dam);
2473
2509 if (!success) 2474 if (!success)
2510 { 2475 {
2511 if (spell->stats.dam < 0) 2476 if (spell->stats.dam < 0)
2512 new_draw_info (NDI_UNIQUE, 0, op, "It can be no brighter here."); 2477 new_draw_info (NDI_UNIQUE, 0, op, "It can be no brighter here.");
2513 else 2478 else
2538 2503
2539 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); 2504 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell);
2540 2505
2541 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2506 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2542 2507
2543 set_owner (new_aura, op); 2508 new_aura->set_owner (op);
2544 set_spell_skill (op, caster, spell, new_aura); 2509 set_spell_skill (op, caster, spell, new_aura);
2545 new_aura->attacktype = spell->attacktype; 2510 new_aura->attacktype = spell->attacktype;
2546 2511
2547 new_aura->level = caster_level (caster, spell); 2512 new_aura->level = caster_level (caster, spell);
2548 if (refresh) 2513 if (refresh)
2590 { 2555 {
2591 aura->destroy (); 2556 aura->destroy ();
2592 return; 2557 return;
2593 } 2558 }
2594 2559
2595 aura->x = env->x;
2596 aura->y = env->y;
2597
2598 /* we need to jump out of the inventory for a bit 2560 /* we need to jump out of the inventory for a bit
2599 * in order to hit the map conveniently. 2561 * in order to hit the map conveniently.
2600 */ 2562 */
2601 insert_ob_in_map (aura, env->map, aura, 0); 2563 aura->insert_at (env, aura);
2602 2564
2603 for (i = 1; i < 9; i++) 2565 for (i = 1; i < 9; i++)
2604 { 2566 {
2605 sint16 nx, ny; 2567 sint16 nx, ny;
2606 2568
2615 if (!(mflags & P_OUT_OF_MAP) && !(OB_TYPE_MOVE_BLOCK (env, GET_MAP_MOVE_BLOCK (m, nx, ny)))) 2577 if (!(mflags & P_OUT_OF_MAP) && !(OB_TYPE_MOVE_BLOCK (env, GET_MAP_MOVE_BLOCK (m, nx, ny))))
2616 { 2578 {
2617 hit_map (aura, i, aura->attacktype, 0); 2579 hit_map (aura, i, aura->attacktype, 0);
2618 2580
2619 if (aura->other_arch) 2581 if (aura->other_arch)
2620 { 2582 m->insert (arch_to_object (aura->other_arch), nx, ny, aura);
2621 object *new_ob;
2622
2623 new_ob = arch_to_object (aura->other_arch);
2624 new_ob->x = nx;
2625 new_ob->y = ny;
2626 insert_ob_in_map (new_ob, m, aura, 0);
2627 } 2583 }
2628 }
2629 } 2584 }
2585
2630 /* put the aura back in the player's inventory */ 2586 /* put the aura back in the player's inventory */
2631 aura->remove (); 2587 aura->remove ();
2632 insert_ob_in_ob (aura, env); 2588 insert_ob_in_ob (aura, env);
2633} 2589}
2634 2590
2639void 2595void
2640move_peacemaker (object *op) 2596move_peacemaker (object *op)
2641{ 2597{
2642 object *tmp; 2598 object *tmp;
2643 2599
2644 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 2600 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
2645 { 2601 {
2646 int atk_lev, def_lev; 2602 int atk_lev, def_lev;
2647 object *victim = tmp; 2603 object *victim = tmp;
2648 2604
2649 if (tmp->head) 2605 if (tmp->head)
2660 2616
2661 if (rndm (0, atk_lev - 1) > def_lev) 2617 if (rndm (0, atk_lev - 1) > def_lev)
2662 { 2618 {
2663 /* make this sucker peaceful. */ 2619 /* make this sucker peaceful. */
2664 2620
2665 change_exp (get_owner (op), victim->stats.exp, op->skill, 0); 2621 change_exp (op->owner, victim->stats.exp, op->skill, 0);
2666 victim->stats.exp = 0; 2622 victim->stats.exp = 0;
2667#if 0 2623#if 0
2668 /* No idea why these were all set to zero - if something 2624 /* No idea why these were all set to zero - if something
2669 * makes this creature agressive, he should still do damage. 2625 * makes this creature agressive, he should still do damage.
2670 */ 2626 */
2715 2671
2716 snprintf (rune, sizeof (rune), "%s\n", msg); 2672 snprintf (rune, sizeof (rune), "%s\n", msg);
2717 2673
2718 tmp->race = op->name; /*Save the owner of the rune */ 2674 tmp->race = op->name; /*Save the owner of the rune */
2719 tmp->msg = rune; 2675 tmp->msg = rune;
2720 tmp->x = op->x; 2676
2721 tmp->y = op->y; 2677 tmp->insert_at (op, op, INS_BELOW_ORIGINATOR);
2722 insert_ob_in_map (tmp, op->map, op, INS_BELOW_ORIGINATOR);
2723 return 1; 2678 return 1;
2724} 2679}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines