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.15 by root, Sat Dec 9 16:11:09 2006 UTC vs.
Revision 1.25 by root, Sat Dec 23 09:58:23 2006 UTC

74 if (!(random_roll (0, 3, op, PREFER_HIGH))) 74 if (!(random_roll (0, 3, op, PREFER_HIGH)))
75 { 75 {
76 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand)); 76 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s vibrates violently, then explodes!", query_name (wand));
77 play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE); 77 play_sound_map (op->map, op->x, op->y, SOUND_OB_EXPLODE);
78 esrv_del_item (op->contr, wand->count); 78 esrv_del_item (op->contr, wand->count);
79 remove_ob (wand); 79 wand->destroy ();
80 free_object (wand);
81 tmp = get_archetype ("fireball"); 80 tmp = get_archetype ("fireball");
82 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10; 81 tmp->stats.dam = (spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob)) / 10;
83 if (!tmp->stats.dam) 82 if (!tmp->stats.dam)
84 tmp->stats.dam = 1; 83 tmp->stats.dam = 1;
85 tmp->stats.hp = tmp->stats.dam / 2; 84 tmp->stats.hp = tmp->stats.dam / 2;
158 if (!strcasecmp (al->item->name, stringarg)) 157 if (!strcasecmp (al->item->name, stringarg))
159 break; 158 break;
160 159
161 if (!al) 160 if (!al)
162 { 161 {
163 free_object (missile); 162 missile->destroy ();
164 new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg); 163 new_draw_info_format (NDI_UNIQUE, 0, op, "No such object %ss of %s", missile_name, stringarg);
165 return 0; 164 return 0;
166 } 165 }
167 166
168 if (al->item->slaying) 167 if (al->item->slaying)
169 { 168 {
170 free_object (missile); 169 missile->destroy ();
171 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg); 170 new_draw_info_format (NDI_UNIQUE, 0, op, "You are not allowed to create %ss of %s", missile_name, stringarg);
172 return 0; 171 return 0;
173 } 172 }
174 173
175 give_artifact_abilities (missile, al->item); 174 give_artifact_abilities (missile, al->item);
303 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic."); 302 new_draw_info (NDI_UNIQUE, 0, op, "Something blocks your magic.");
304 return 0; 303 return 0;
305 } 304 }
306 if (mflags & P_IS_ALIVE) 305 if (mflags & P_IS_ALIVE)
307 { 306 {
308 for (tmp = get_map_ob (m, x, y); tmp != NULL; tmp = tmp->above) 307 for (tmp = GET_MAP_OB (m, x, y); tmp != NULL; tmp = tmp->above)
309 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER))) 308 if (QUERY_FLAG (tmp, FLAG_ALIVE) && (tmp->type == PLAYER || QUERY_FLAG (tmp, FLAG_MONSTER)))
310 { 309 {
311 new_draw_info (NDI_UNIQUE, 0, op, "You detect something."); 310 new_draw_info (NDI_UNIQUE, 0, op, "You detect something.");
312 if (tmp->head != NULL) 311 if (tmp->head != NULL)
313 tmp = tmp->head; 312 tmp = tmp->head;
441 440
442 if (mflags & P_OUT_OF_MAP) 441 if (mflags & P_OUT_OF_MAP)
443 continue; 442 continue;
444 443
445 // earth to dust tears down everything that can be teared down 444 // earth to dust tears down everything that can be teared down
446 for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) 445 for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next)
447 { 446 {
448 next = tmp->above; 447 next = tmp->above;
449 if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN)) 448 if (QUERY_FLAG (tmp, FLAG_TEAR_DOWN))
450 hit_player (tmp, 9998, op, AT_PHYSICAL, 0); 449 hit_player (tmp, 9998, op, AT_PHYSICAL, 0);
451 } 450 }
466 if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST))) 465 if ((get_map_flags (op->map, NULL, op->x, op->y, NULL, NULL) & P_NO_CLERIC) && (!QUERY_FLAG (op, FLAG_WIZCAST)))
467 new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you."); 466 new_draw_info (NDI_UNIQUE, 0, op, "You feel something fizzle inside you.");
468 else 467 else
469 enter_exit (op, wor); 468 enter_exit (op, wor);
470 469
471 remove_ob (wor); 470 wor->destroy ();
472 free_object (wor);
473} 471}
474 472
475/* Word of recall causes the player to return 'home'. 473/* Word of recall causes the player to return 'home'.
476 * we put a force into the player object, so that there is a 474 * we put a force into the player object, so that there is a
477 * time delay effect. 475 * time delay effect.
557 } 555 }
558 return cast_spell (op, caster, dir, newspell, NULL); 556 return cast_spell (op, caster, dir, newspell, NULL);
559 } 557 }
560 return 1; 558 return 1;
561} 559}
562
563 560
564int 561int
565perceive_self (object *op) 562perceive_self (object *op)
566{ 563{
567 char *cp = describe_item (op, op), buf[MAX_BUF]; 564 char *cp = describe_item (op, op), buf[MAX_BUF];
643 char portal_name[1024], portal_message[1024]; 640 char portal_name[1024], portal_message[1024];
644 sint16 exitx, exity; 641 sint16 exitx, exity;
645 maptile *exitmap; 642 maptile *exitmap;
646 int op_level; 643 int op_level;
647 644
648
649 /* Check to see if the map the player is currently on is a per player unique 645 /* Check to see if the map the player is currently on is a per player unique
650 * map. This can be determined in that per player unique maps have the 646 * map. This can be determined in that per player unique maps have the
651 * full pathname listed. 647 * full pathname listed.
652 */ 648 */
653 if (!strncmp (op->map->path, settings.localdir, strlen (settings.localdir)) && settings.create_home_portals != TRUE) 649 if (!strncmp (op->map->path, settings.localdir, strlen (settings.localdir)) && settings.create_home_portals != TRUE)
661 */ 657 */
662 dummy = arch_to_object (spell->other_arch); 658 dummy = arch_to_object (spell->other_arch);
663 if (dummy == NULL) 659 if (dummy == NULL)
664 { 660 {
665 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 661 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
666 LOG (llevError, "get_object failed (force in cast_create_town_portal for %s!\n", &op->name); 662 LOG (llevError, "object::create failed (force in cast_create_town_portal for %s!\n", &op->name);
667 return 0; 663 return 0;
668 } 664 }
665
669 force = check_inv_recursive (op, dummy); 666 force = check_inv_recursive (op, dummy);
670 667
671 if (force == NULL) 668 if (force == NULL)
672 { 669 {
673 /* Here we know there is no destination marked up. 670 /* Here we know there is no destination marked up.
680 EXIT_Y (dummy) = op->y; 677 EXIT_Y (dummy) = op->y;
681 insert_ob_in_ob (dummy, op); 678 insert_ob_in_ob (dummy, op);
682 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You fix this place in your mind.\nYou feel you are able to come here from anywhere."); 679 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You fix this place in your mind.\nYou feel you are able to come here from anywhere.");
683 return 1; 680 return 1;
684 } 681 }
685 free_object (dummy); 682
683 dummy->destroy ();
686 684
687 /* Here we know where the town portal should go to 685 /* Here we know where the town portal should go to
688 * We should kill any existing portal associated with the player. 686 * We should kill any existing portal associated with the player.
689 * Than we should create the 2 portals. 687 * Than we should create the 2 portals.
690 * For each of them, we need: 688 * For each of them, we need:
703 /* First step: killing existing town portals */ 701 /* First step: killing existing town portals */
704 dummy = get_archetype (spell->race); 702 dummy = get_archetype (spell->race);
705 if (dummy == NULL) 703 if (dummy == NULL)
706 { 704 {
707 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 705 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
708 LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); 706 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
709 return 0; 707 return 0;
710 } 708 }
709
711 perm_portal = archetype::find (spell->slaying); 710 perm_portal = archetype::find (spell->slaying);
712 711
713 /* To kill a town portal, we go trough the player's inventory, 712 /* To kill a town portal, we go trough the player's inventory,
714 * for each marked portal in player's inventory, 713 * for each marked portal in player's inventory,
715 * -We try load the associated map (if impossible, consider the portal destructed) 714 * -We try load the associated map (if impossible, consider the portal destructed)
733 tmp = present_arch (perm_portal, exitmap, exitx, exity); 732 tmp = present_arch (perm_portal, exitmap, exitx, exity);
734 while (tmp) 733 while (tmp)
735 { 734 {
736 if (tmp->name == old_force->name) 735 if (tmp->name == old_force->name)
737 { 736 {
738 remove_ob (tmp); 737 tmp->destroy ();
739 free_object (tmp);
740 break; 738 break;
741 } 739 }
742 else 740
743 {
744 tmp = tmp->above; 741 tmp = tmp->above;
745 }
746 } 742 }
747 } 743 }
748 remove_ob (old_force); 744
749 free_object (old_force); 745 old_force->destroy ();
750 LOG (llevDebug, "\n"); 746 LOG (llevDebug, "\n");
751 } 747 }
752 free_object (dummy); 748
749 dummy->destroy ();
753 750
754 /* Creating the portals. 751 /* Creating the portals.
755 * The very first thing to do is to ensure 752 * The very first thing to do is to ensure
756 * access to the destination map. 753 * access to the destination map.
757 * If we can't, don't fizzle. Simply warn player. 754 * If we can't, don't fizzle. Simply warn player.
769 766
770 /* If we were unable to load (ex. random map deleted), warn player */ 767 /* If we were unable to load (ex. random map deleted), warn player */
771 if (exitmap == NULL) 768 if (exitmap == NULL)
772 { 769 {
773 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); 770 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?");
774 remove_ob (force); 771 force->destroy ();
775 free_object (force);
776 return 1; 772 return 1;
777 } 773 }
778 774
779 op_level = caster_level (caster, spell); 775 op_level = caster_level (caster, spell);
780 if (op_level < 15) 776 if (op_level < 15)
798 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name); 794 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name);
799 dummy = get_archetype (spell->slaying); /*The portal */ 795 dummy = get_archetype (spell->slaying); /*The portal */
800 if (dummy == NULL) 796 if (dummy == NULL)
801 { 797 {
802 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 798 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
803 LOG (llevError, "get_object failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); 799 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
804 return 0; 800 return 0;
805 } 801 }
802
806 EXIT_PATH (dummy) = force->name; 803 EXIT_PATH (dummy) = force->name;
807 EXIT_X (dummy) = EXIT_X (force); 804 EXIT_X (dummy) = EXIT_X (force);
808 EXIT_Y (dummy) = EXIT_Y (force); 805 EXIT_Y (dummy) = EXIT_Y (force);
809 dummy->name = dummy->name_pl = portal_name; 806 dummy->name = dummy->name_pl = portal_name;
810 dummy->msg = portal_message; 807 dummy->msg = portal_message;
817 */ 814 */
818 tmp = get_archetype (spell->race); 815 tmp = get_archetype (spell->race);
819 if (tmp == NULL) 816 if (tmp == NULL)
820 { 817 {
821 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 818 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
822 LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); 819 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
823 return 0; 820 return 0;
824 } 821 }
822
825 tmp->race = op->map->path; 823 tmp->race = op->map->path;
826 tmp->name = portal_name; 824 tmp->name = portal_name;
827 EXIT_X (tmp) = dummy->x; 825 EXIT_X (tmp) = dummy->x;
828 EXIT_Y (tmp) = dummy->y; 826 EXIT_Y (tmp) = dummy->y;
829 insert_ob_in_ob (tmp, op); 827 insert_ob_in_ob (tmp, op);
837 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); 835 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path);
838 dummy = get_archetype (spell->slaying); /*The portal */ 836 dummy = get_archetype (spell->slaying); /*The portal */
839 if (dummy == NULL) 837 if (dummy == NULL)
840 { 838 {
841 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 839 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
842 LOG (llevError, "get_object failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name); 840 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
843 return 0; 841 return 0;
844 } 842 }
843
845 EXIT_PATH (dummy) = op->map->path; 844 EXIT_PATH (dummy) = op->map->path;
846 EXIT_X (dummy) = op->x; 845 EXIT_X (dummy) = op->x;
847 EXIT_Y (dummy) = op->y; 846 EXIT_Y (dummy) = op->y;
848 dummy->name = dummy->name_pl = portal_name; 847 dummy->name = dummy->name_pl = portal_name;
849 dummy->msg = portal_message; 848 dummy->msg = portal_message;
857 */ 856 */
858 tmp = get_archetype (spell->race); 857 tmp = get_archetype (spell->race);
859 if (tmp == NULL) 858 if (tmp == NULL)
860 { 859 {
861 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 860 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!");
862 LOG (llevError, "get_object failed (force) in cast_create_town_portal for %s!\n", &op->name); 861 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
863 return 0; 862 return 0;
864 } 863 }
864
865 tmp->race = force->name; 865 tmp->race = force->name;
866 tmp->name = portal_name; 866 tmp->name = portal_name;
867 EXIT_X (tmp) = dummy->x; 867 EXIT_X (tmp) = dummy->x;
868 EXIT_Y (tmp) = dummy->y; 868 EXIT_Y (tmp) = dummy->y;
869 insert_ob_in_ob (tmp, op); 869 insert_ob_in_ob (tmp, op);
870 870
871 /* Describe the player what happened 871 /* Describe the player what happened
872 */ 872 */
873 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home."); 873 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home.");
874 remove_ob (force); /* Delete the force inside the player */ 874 force->destroy ();
875 free_object (force); 875
876 return 1; 876 return 1;
877} 877}
878
879 878
880/* This creates magic walls. Really, it can create most any object, 879/* This creates magic walls. Really, it can create most any object,
881 * within some reason. 880 * within some reason.
882 */ 881 */
883
884int 882int
885magic_wall (object *op, object *caster, int dir, object *spell_ob) 883magic_wall (object *op, object *caster, int dir, object *spell_ob)
886{ 884{
887 object *tmp, *tmp2; 885 object *tmp, *tmp2;
888 int i, posblocked, negblocked, maxrange; 886 int i, posblocked, negblocked, maxrange;
900 else 898 else
901 { 899 {
902 x = op->x + freearr_x[dir]; 900 x = op->x + freearr_x[dir];
903 y = op->y + freearr_y[dir]; 901 y = op->y + freearr_y[dir];
904 } 902 }
903
905 m = op->map; 904 m = op->map;
906 905
907 if ((spell_ob->move_block || x != op->x || y != op->y) && 906 if ((spell_ob->move_block || x != op->x || y != op->y) &&
908 (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) || 907 (get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE) ||
909 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block))) 908 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block)))
910 { 909 {
911 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 910 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
912 return 0; 911 return 0;
913 } 912 }
913
914 if (spell_ob->other_arch) 914 if (spell_ob->other_arch)
915 {
916 tmp = arch_to_object (spell_ob->other_arch); 915 tmp = arch_to_object (spell_ob->other_arch);
917 }
918 else if (spell_ob->race) 916 else if (spell_ob->race)
919 { 917 {
920 char buf1[MAX_BUF]; 918 char buf1[MAX_BUF];
921 919
922 sprintf (buf1, spell_ob->race, dir); 920 sprintf (buf1, spell_ob->race, dir);
944 } 942 }
945 else if (QUERY_FLAG (tmp, FLAG_ALIVE)) 943 else if (QUERY_FLAG (tmp, FLAG_ALIVE))
946 { 944 {
947 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 945 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
948 tmp->stats.maxhp = tmp->stats.hp; 946 tmp->stats.maxhp = tmp->stats.hp;
949 set_owner (tmp, op);
950 set_spell_skill (op, caster, spell_ob, tmp);
951 } 947 }
948
952 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) 949 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP))
953 { 950 {
954 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 951 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
955 SET_FLAG (tmp, FLAG_IS_USED_UP); 952 SET_FLAG (tmp, FLAG_IS_USED_UP);
956 } 953 }
954
957 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN)) 955 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN))
958 { 956 {
959 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 957 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
960 tmp->stats.maxhp = tmp->stats.hp; 958 tmp->stats.maxhp = tmp->stats.hp;
961 SET_FLAG (tmp, FLAG_TEAR_DOWN); 959 SET_FLAG (tmp, FLAG_TEAR_DOWN);
962 SET_FLAG (tmp, FLAG_ALIVE); 960 SET_FLAG (tmp, FLAG_ALIVE);
963 } 961 }
964 962
965 /* This can't really hurt - if the object doesn't kill anything, 963 /* This can't really hurt - if the object doesn't kill anything,
966 * these fields just won't be used. 964 * these fields just won't be used. Do not set the owner for
965 * earthwalls, though, so they survive restarts.
967 */ 966 */
968 set_owner (tmp, op); 967 if (tmp->type != EARTHWALL) //TODO
968 tmp->set_owner (op);
969
969 set_spell_skill (op, caster, spell_ob, tmp); 970 set_spell_skill (op, caster, spell_ob, tmp);
970 tmp->x = x; 971 tmp->x = x;
971 tmp->y = y; 972 tmp->y = y;
972 tmp->level = caster_level (caster, spell_ob) / 2; 973 tmp->level = caster_level (caster, spell_ob) / 2;
973 974
975 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) 976 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL)
976 { 977 {
977 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name); 978 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name);
978 return 0; 979 return 0;
979 } 980 }
981
980 /* If this is a spellcasting wall, need to insert the spell object */ 982 /* If this is a spellcasting wall, need to insert the spell object */
981 if (tmp->other_arch && tmp->other_arch->clone.type == SPELL) 983 if (tmp->other_arch && tmp->other_arch->clone.type == SPELL)
982 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp); 984 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp);
983 985
984 /* This code causes the wall to extend some distance in 986 /* This code causes the wall to extend some distance in
1002 m = tmp->map; 1004 m = tmp->map;
1003 1005
1004 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 1006 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) &&
1005 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked) 1007 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked)
1006 { 1008 {
1007 tmp2 = get_object (); 1009 tmp2 = tmp->clone ();
1008 copy_object (tmp, tmp2);
1009 tmp2->x = x; 1010 tmp2->x = x;
1010 tmp2->y = y; 1011 tmp2->y = y;
1011 insert_ob_in_map (tmp2, m, op, 0); 1012 insert_ob_in_map (tmp2, m, op, 0);
1012 /* If this is a spellcasting wall, need to insert the spell object */ 1013 /* If this is a spellcasting wall, need to insert the spell object */
1013 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) 1014 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
1022 m = tmp->map; 1023 m = tmp->map;
1023 1024
1024 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 1025 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) &&
1025 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked) 1026 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked)
1026 { 1027 {
1027 tmp2 = get_object (); 1028 tmp2 = tmp->clone ();
1028 copy_object (tmp, tmp2);
1029 tmp2->x = x; 1029 tmp2->x = x;
1030 tmp2->y = y; 1030 tmp2->y = y;
1031 insert_ob_in_map (tmp2, m, op, 0); 1031 insert_ob_in_map (tmp2, m, op, 0);
1032 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) 1032 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
1033 insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); 1033 insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2);
1145 return 0; 1145 return 0;
1146 } 1146 }
1147 } 1147 }
1148 1148
1149 /* Actually move the player now */ 1149 /* Actually move the player now */
1150 remove_ob (op); 1150 op->remove ();
1151 op->x += freearr_x[dir] * dist; 1151 op->x += freearr_x[dir] * dist;
1152 op->y += freearr_y[dir] * dist; 1152 op->y += freearr_y[dir] * dist;
1153 if ((op = insert_ob_in_map (op, op->map, op, 0)) == NULL) 1153 if ((op = insert_ob_in_map (op, op->map, op, 0)) == NULL)
1154 return 1; 1154 return 1;
1155 1155
1432 force->stats.ac = spell_ob->stats.ac; 1432 force->stats.ac = spell_ob->stats.ac;
1433 force->attacktype = spell_ob->attacktype; 1433 force->attacktype = spell_ob->attacktype;
1434 1434
1435 insert_ob_in_ob (force, tmp); 1435 insert_ob_in_ob (force, tmp);
1436 change_abil (tmp, force); /* Mostly to display any messages */ 1436 change_abil (tmp, force); /* Mostly to display any messages */
1437 fix_player (tmp); 1437 tmp->update_stats ();
1438 return 1; 1438 return 1;
1439} 1439}
1440 1440
1441/* This used to be part of cast_change_ability, but it really didn't make 1441/* This used to be part of cast_change_ability, but it really didn't make
1442 * a lot of sense, since most of the values it derives are from the god 1442 * a lot of sense, since most of the values it derives are from the god
1541 force->stats.wc = spell_ob->stats.wc; 1541 force->stats.wc = spell_ob->stats.wc;
1542 force->stats.ac = spell_ob->stats.ac; 1542 force->stats.ac = spell_ob->stats.ac;
1543 1543
1544 change_abil (tmp, force); /* Mostly to display any messages */ 1544 change_abil (tmp, force); /* Mostly to display any messages */
1545 insert_ob_in_ob (force, tmp); 1545 insert_ob_in_ob (force, tmp);
1546 fix_player (tmp); 1546 tmp->update_stats ();
1547 return 1; 1547 return 1;
1548} 1548}
1549 1549
1550 1550
1551 1551
1621 *small_nuggets -= large->value / small->value; 1621 *small_nuggets -= large->value / small->value;
1622 if (*small_nuggets && large->value % small->value) 1622 if (*small_nuggets && large->value % small->value)
1623 (*small_nuggets)--; 1623 (*small_nuggets)--;
1624 } 1624 }
1625 weight += obj->weight; 1625 weight += obj->weight;
1626 remove_ob (obj); 1626 obj->destroy ();
1627 free_object (obj);
1628} 1627}
1629 1628
1630static void 1629static void
1631update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y) 1630update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y)
1632{ 1631{
1639 if (x == op->x && y == op->y && op->map == m) 1638 if (x == op->x && y == op->y && op->map == m)
1640 flag = INS_BELOW_ORIGINATOR; 1639 flag = INS_BELOW_ORIGINATOR;
1641 1640
1642 if (small_nuggets) 1641 if (small_nuggets)
1643 { 1642 {
1644 tmp = get_object (); 1643 tmp = small->clone ();
1645 copy_object (small, tmp);
1646 tmp->nrof = small_nuggets; 1644 tmp->nrof = small_nuggets;
1647 tmp->x = x; 1645 tmp->x = x;
1648 tmp->y = y; 1646 tmp->y = y;
1649 insert_ob_in_map (tmp, m, op, flag); 1647 insert_ob_in_map (tmp, m, op, flag);
1650 } 1648 }
1649
1651 if (large_nuggets) 1650 if (large_nuggets)
1652 { 1651 {
1653 tmp = get_object (); 1652 tmp = large->clone ();
1654 copy_object (large, tmp);
1655 tmp->nrof = large_nuggets; 1653 tmp->nrof = large_nuggets;
1656 tmp->x = x; 1654 tmp->x = x;
1657 tmp->y = y; 1655 tmp->y = y;
1658 insert_ob_in_map (tmp, m, op, flag); 1656 insert_ob_in_map (tmp, m, op, flag);
1659 } 1657 }
1700 continue; 1698 continue;
1701 1699
1702 small_nuggets = 0; 1700 small_nuggets = 0;
1703 large_nuggets = 0; 1701 large_nuggets = 0;
1704 1702
1705 for (tmp = get_map_ob (mp, nx, ny); tmp != NULL; tmp = next) 1703 for (tmp = GET_MAP_OB (mp, nx, ny); tmp != NULL; tmp = next)
1706 { 1704 {
1707 next = tmp->above; 1705 next = tmp->above;
1708 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) && 1706 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) &&
1709 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 1707 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON))
1710 { 1708 {
1724 alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); 1722 alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight);
1725 1723
1726 if (weight > weight_max) 1724 if (weight > weight_max)
1727 { 1725 {
1728 update_map (op, mp, small_nuggets, large_nuggets, nx, ny); 1726 update_map (op, mp, small_nuggets, large_nuggets, nx, ny);
1729 free_object (large); 1727 large->destroy ();
1730 free_object (small); 1728 small->destroy ();
1731 return 1; 1729 return 1;
1732 } 1730 }
1733 } /* is alchemable object */ 1731 } /* is alchemable object */
1734 } /* process all objects on this space */ 1732 } /* process all objects on this space */
1735 1733
1738 * with this spell. 1736 * with this spell.
1739 */ 1737 */
1740 update_map (op, mp, small_nuggets, large_nuggets, nx, ny); 1738 update_map (op, mp, small_nuggets, large_nuggets, nx, ny);
1741 } 1739 }
1742 } 1740 }
1743 free_object (large); 1741
1744 free_object (small); 1742 large->destroy ();
1743 small->destroy ();
1745 /* reset this so that if player standing on a big pile of stuff, 1744 /* reset this so that if player standing on a big pile of stuff,
1746 * it is redrawn properly. 1745 * it is redrawn properly.
1747 */ 1746 */
1748 op->contr->socket.look_position = 0; 1747 op->contr->ns->look_position = 0;
1749 return 1; 1748 return 1;
1750} 1749}
1751 1750
1752 1751
1753/* This function removes the cursed/damned status on equipped 1752/* This function removes the cursed/damned status on equipped
1762 for (tmp = op->inv; tmp; tmp = tmp->below) 1761 for (tmp = op->inv; tmp; tmp = tmp->below)
1763 if (QUERY_FLAG (tmp, FLAG_APPLIED) && 1762 if (QUERY_FLAG (tmp, FLAG_APPLIED) &&
1764 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || 1763 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) ||
1765 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) 1764 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED))))
1766 { 1765 {
1767
1768 was_one++; 1766 was_one++;
1769 if (tmp->level <= caster_level (caster, spell)) 1767 if (tmp->level <= caster_level (caster, spell))
1770 { 1768 {
1771 success++; 1769 success++;
1772 if (QUERY_FLAG (spell, FLAG_DAMNED)) 1770 if (QUERY_FLAG (spell, FLAG_DAMNED))
1792 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); 1790 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse.");
1793 else 1791 else
1794 new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); 1792 new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items.");
1795 } 1793 }
1796 } 1794 }
1795
1797 return success; 1796 return success;
1798} 1797}
1799 1798
1800/* Identifies objects in the players inventory/on the ground */ 1799/* Identifies objects in the players inventory/on the ground */
1801 1800
1808 num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1807 num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1809 1808
1810 if (num_ident < 1) 1809 if (num_ident < 1)
1811 num_ident = 1; 1810 num_ident = 1;
1812 1811
1813
1814 for (tmp = op->inv; tmp; tmp = tmp->below) 1812 for (tmp = op->inv; tmp; tmp = tmp->below)
1815 { 1813 {
1816 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1814 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1817 { 1815 {
1818 identify (tmp); 1816 identify (tmp);
1817
1819 if (op->type == PLAYER) 1818 if (op->type == PLAYER)
1820 { 1819 {
1821 new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op)); 1820 new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op));
1821
1822 if (tmp->msg) 1822 if (tmp->msg)
1823 { 1823 {
1824 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); 1824 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1825 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 1825 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1826 } 1826 }
1827 } 1827 }
1828
1828 num_ident--; 1829 num_ident--;
1829 success = 1; 1830 success = 1;
1830 if (!num_ident) 1831 if (!num_ident)
1831 break; 1832 break;
1832 } 1833 }
1833 } 1834 }
1835
1834 /* If all the power of the spell has been used up, don't go and identify 1836 /* If all the power of the spell has been used up, don't go and identify
1835 * stuff on the floor. Only identify stuff on the floor if the spell 1837 * stuff on the floor. Only identify stuff on the floor if the spell
1836 * was not fully used. 1838 * was not fully used.
1837 */ 1839 */
1838 if (num_ident) 1840 if (num_ident)
1839 { 1841 {
1840 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1842 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
1841 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1843 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1842 { 1844 {
1843
1844 identify (tmp); 1845 identify (tmp);
1846
1845 if (op->type == PLAYER) 1847 if (op->type == PLAYER)
1846 { 1848 {
1847 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op)); 1849 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op));
1850
1848 if (tmp->msg) 1851 if (tmp->msg)
1849 { 1852 {
1850 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); 1853 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1851 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 1854 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1852 } 1855 }
1856
1853 esrv_send_item (op, tmp); 1857 esrv_send_item (op, tmp);
1854 } 1858 }
1859
1855 num_ident--; 1860 num_ident--;
1856 success = 1; 1861 success = 1;
1857 if (!num_ident) 1862 if (!num_ident)
1858 break; 1863 break;
1859 } 1864 }
1860 } 1865 }
1866
1861 if (!success) 1867 if (!success)
1862 new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); 1868 new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified.");
1863 else 1869 else
1864 {
1865 spell_effect (spell, op->x, op->y, op->map, op); 1870 spell_effect (spell, op->x, op->y, op->map, op);
1866 } 1871
1867 return success; 1872 return success;
1868} 1873}
1869
1870 1874
1871int 1875int
1872cast_detection (object *op, object *caster, object *spell, object *skill) 1876cast_detection (object *op, object *caster, object *spell, object *skill)
1873{ 1877{
1874 object *tmp, *last, *god, *detect; 1878 object *tmp, *last, *god, *detect;
1887 skill = caster; 1891 skill = caster;
1888 1892
1889 for (x = op->x - range; x <= op->x + range; x++) 1893 for (x = op->x - range; x <= op->x + range; x++)
1890 for (y = op->y - range; y <= op->y + range; y++) 1894 for (y = op->y - range; y <= op->y + range; y++)
1891 { 1895 {
1892
1893 m = op->map; 1896 m = op->map;
1894 mflags = get_map_flags (m, &m, x, y, &nx, &ny); 1897 mflags = get_map_flags (m, &m, x, y, &nx, &ny);
1895 if (mflags & P_OUT_OF_MAP) 1898 if (mflags & P_OUT_OF_MAP)
1896 continue; 1899 continue;
1897 1900
1899 * floor. But this is not true for show invisible. 1902 * floor. But this is not true for show invisible.
1900 * Basically, we just go and find the top object and work 1903 * Basically, we just go and find the top object and work
1901 * down - that is easier than working up. 1904 * down - that is easier than working up.
1902 */ 1905 */
1903 1906
1904 for (last = NULL, tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) 1907 for (last = NULL, tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above)
1905 last = tmp; 1908 last = tmp;
1909
1906 /* Shouldn't happen, but if there are no objects on a space, this 1910 /* Shouldn't happen, but if there are no objects on a space, this
1907 * would happen. 1911 * would happen.
1908 */ 1912 */
1909 if (!last) 1913 if (!last)
1910 continue; 1914 continue;
1912 done_one = 0; 1916 done_one = 0;
1913 floor = 0; 1917 floor = 0;
1914 detect = NULL; 1918 detect = NULL;
1915 for (tmp = last; tmp; tmp = tmp->below) 1919 for (tmp = last; tmp; tmp = tmp->below)
1916 { 1920 {
1917
1918 /* show invisible */ 1921 /* show invisible */
1919 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && 1922 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) &&
1920 /* Might there be other objects that we can make visibile? */ 1923 /* Might there be other objects that we can make visible? */
1921 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || 1924 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) ||
1922 (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || 1925 (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) ||
1923 tmp->type == CF_HANDLE || 1926 tmp->type == CF_HANDLE ||
1924 tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || 1927 tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE ||
1925 tmp->type == BUTTON || tmp->type == TELEPORTER || 1928 tmp->type == BUTTON || tmp->type == TELEPORTER ||
1932 { 1935 {
1933 tmp->invisible = 0; 1936 tmp->invisible = 0;
1934 done_one = 1; 1937 done_one = 1;
1935 } 1938 }
1936 } 1939 }
1940
1937 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1941 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1938 floor = 1; 1942 floor = 1;
1939 1943
1940 /* All detections below this point don't descend beneath the floor, 1944 /* All detections below this point don't descend beneath the floor,
1941 * so just continue on. We could be clever and look at the type of 1945 * so just continue on. We could be clever and look at the type of
2111 2115
2112 mflags = get_map_flags (m, &m, x, y, &x, &y); 2116 mflags = get_map_flags (m, &m, x, y, &x, &y);
2113 2117
2114 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 2118 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
2115 { 2119 {
2116 for (plyr = get_map_ob (m, x, y); plyr != NULL; plyr = plyr->above) 2120 for (plyr = GET_MAP_OB (m, x, y); plyr != NULL; plyr = plyr->above)
2117 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 2121 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE))
2118 break; 2122 break;
2119 } 2123 }
2120 2124
2121 2125
2122 /* If we did not find a player in the specified direction, transfer 2126 /* If we did not find a player in the specified direction, transfer
2123 * to anyone on top of us. This is used for the rune of transference mostly. 2127 * to anyone on top of us. This is used for the rune of transference mostly.
2124 */ 2128 */
2125 if (plyr == NULL) 2129 if (plyr == NULL)
2126 for (plyr = get_map_ob (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above) 2130 for (plyr = GET_MAP_OB (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above)
2127 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 2131 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE))
2128 break; 2132 break;
2129 2133
2130 if (!plyr) 2134 if (!plyr)
2131 { 2135 {
2186 m = op->map; 2190 m = op->map;
2187 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 2191 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
2188 if (mflags & P_OUT_OF_MAP) 2192 if (mflags & P_OUT_OF_MAP)
2189 return; 2193 return;
2190 2194
2191 for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) 2195 for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next)
2192 { 2196 {
2193 next = tmp->above; 2197 next = tmp->above;
2194 2198
2195 /* Need to look at the head object - otherwise, if tmp 2199 /* Need to look at the head object - otherwise, if tmp
2196 * points to a monster, we don't have all the necessary 2200 * points to a monster, we don't have all the necessary
2210 * monsters either. 2214 * monsters either.
2211 */ 2215 */
2212 2216
2213 if (head->attacktype & AT_MAGIC && 2217 if (head->attacktype & AT_MAGIC &&
2214 !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) 2218 !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level))
2215 { 2219 head->destroy ();
2216 remove_ob (head);
2217 free_object (head);
2218 }
2219 else 2220 else
2220 switch (head->type) 2221 switch (head->type)
2221 { 2222 {
2222 case SPELL_EFFECT: 2223 case SPELL_EFFECT:
2223 if (op->level > head->level) 2224 if (op->level > head->level)
2224 { 2225 head->destroy ();
2225 remove_ob (head); 2226
2226 free_object (head);
2227 }
2228 break; 2227 break;
2229 2228
2230 /* I really don't get this rune code that much - that 2229 /* I really don't get this rune code that much - that
2231 * random chance seems really low. 2230 * random chance seems really low.
2232 */ 2231 */
2233 case RUNE: 2232 case RUNE:
2234 if (rndm (0, 149) == 0) 2233 if (rndm (0, 149) == 0)
2235 { 2234 {
2236 head->stats.hp--; /* weaken the rune */ 2235 head->stats.hp--; /* weaken the rune */
2237 if (!head->stats.hp) 2236 if (!head->stats.hp)
2238 { 2237 head->destroy ();
2239 remove_ob (head);
2240 free_object (head);
2241 }
2242 } 2238 }
2243 break; 2239 break;
2244 } 2240 }
2245 } 2241 }
2246} 2242}
2383 CLEAR_FLAG (tmp, FLAG_MONSTER); 2379 CLEAR_FLAG (tmp, FLAG_MONSTER);
2384 SET_FLAG (tmp, FLAG_FRIENDLY); 2380 SET_FLAG (tmp, FLAG_FRIENDLY);
2385 tmp->stats.exp = 0; 2381 tmp->stats.exp = 0;
2386 add_friendly_object (tmp); 2382 add_friendly_object (tmp);
2387 tmp->type = GOLEM; 2383 tmp->type = GOLEM;
2388 set_owner (tmp, op); 2384 tmp->set_owner (op);
2389 set_spell_skill (op, caster, spell, tmp); 2385 set_spell_skill (op, caster, spell, tmp);
2390 op->contr->ranges[range_golem] = tmp; 2386 op->contr->ranges[range_golem] = tmp;
2391 op->contr->shoottype = range_golem; 2387 op->contr->shoottype = range_golem;
2392 2388
2393 /* Give the weapon to the golem now. A bit of a hack to check the 2389 /* Give the weapon to the golem now. A bit of a hack to check the
2394 * removed flag - it should only be set if get_split_object was 2390 * removed flag - it should only be set if get_split_object was
2395 * used above. 2391 * used above.
2396 */ 2392 */
2397 if (!QUERY_FLAG (weapon, FLAG_REMOVED)) 2393 if (!QUERY_FLAG (weapon, FLAG_REMOVED))
2398 remove_ob (weapon); 2394 weapon->remove ();
2399 insert_ob_in_ob (weapon, tmp); 2395 insert_ob_in_ob (weapon, tmp);
2400 esrv_send_item (op, weapon); 2396 esrv_send_item (op, weapon);
2401 /* To do everything necessary to let a golem use the weapon is a pain, 2397 /* To do everything necessary to let a golem use the weapon is a pain,
2402 * so instead, just set it as equipped (otherwise, we need to update 2398 * so instead, just set it as equipped (otherwise, we need to update
2403 * body_info, skills, etc) 2399 * body_info, skills, etc)
2404 */ 2400 */
2405 SET_FLAG (tmp, FLAG_USE_WEAPON); 2401 SET_FLAG (tmp, FLAG_USE_WEAPON);
2406 SET_FLAG (weapon, FLAG_APPLIED); 2402 SET_FLAG (weapon, FLAG_APPLIED);
2407 fix_player (tmp); 2403 tmp->update_stats ();
2408 2404
2409 /* There used to be 'odd' code that basically seemed to take the absolute 2405 /* There used to be 'odd' code that basically seemed to take the absolute
2410 * value of the weapon->magic an use that. IMO, that doesn't make sense - 2406 * value of the weapon->magic an use that. IMO, that doesn't make sense -
2411 * if you're using a crappy weapon, it shouldn't be as good. 2407 * if you're using a crappy weapon, it shouldn't be as good.
2412 */ 2408 */
2550 2546
2551 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); 2547 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell);
2552 2548
2553 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2549 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2554 2550
2555 set_owner (new_aura, op); 2551 new_aura->set_owner (op);
2556 set_spell_skill (op, caster, spell, new_aura); 2552 set_spell_skill (op, caster, spell, new_aura);
2557 new_aura->attacktype = spell->attacktype; 2553 new_aura->attacktype = spell->attacktype;
2558 2554
2559 new_aura->level = caster_level (caster, spell); 2555 new_aura->level = caster_level (caster, spell);
2560 if (refresh) 2556 if (refresh)
2586 env = aura->env; 2582 env = aura->env;
2587 2583
2588 /* no matter what we've gotta remove the aura... 2584 /* no matter what we've gotta remove the aura...
2589 * we'll put it back if its time isn't up. 2585 * we'll put it back if its time isn't up.
2590 */ 2586 */
2591 remove_ob (aura); 2587 aura->remove ();
2592 2588
2593 /* exit if we're out of gas */ 2589 /* exit if we're out of gas */
2594 if (aura->duration-- < 0) 2590 if (aura->duration-- < 0)
2595 { 2591 {
2596 free_object (aura); 2592 aura->destroy ();
2597 return; 2593 return;
2598 } 2594 }
2599 2595
2600 /* auras only exist in inventories */ 2596 /* auras only exist in inventories */
2601 if (env == NULL || env->map == NULL) 2597 if (env == NULL || env->map == NULL)
2602 { 2598 {
2603 free_object (aura); 2599 aura->destroy ();
2604 return; 2600 return;
2605 } 2601 }
2602
2606 aura->x = env->x; 2603 aura->x = env->x;
2607 aura->y = env->y; 2604 aura->y = env->y;
2608 2605
2609 /* we need to jump out of the inventory for a bit 2606 /* we need to jump out of the inventory for a bit
2610 * in order to hit the map conveniently. 2607 * in order to hit the map conveniently.
2637 insert_ob_in_map (new_ob, m, aura, 0); 2634 insert_ob_in_map (new_ob, m, aura, 0);
2638 } 2635 }
2639 } 2636 }
2640 } 2637 }
2641 /* put the aura back in the player's inventory */ 2638 /* put the aura back in the player's inventory */
2642 remove_ob (aura); 2639 aura->remove ();
2643 insert_ob_in_ob (aura, env); 2640 insert_ob_in_ob (aura, env);
2644} 2641}
2645 2642
2646/* moves the peacemaker spell. 2643/* moves the peacemaker spell.
2647 * op is the piece object. 2644 * op is the piece object.
2650void 2647void
2651move_peacemaker (object *op) 2648move_peacemaker (object *op)
2652{ 2649{
2653 object *tmp; 2650 object *tmp;
2654 2651
2655 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 2652 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
2656 { 2653 {
2657 int atk_lev, def_lev; 2654 int atk_lev, def_lev;
2658 object *victim = tmp; 2655 object *victim = tmp;
2659 2656
2660 if (tmp->head) 2657 if (tmp->head)
2671 2668
2672 if (rndm (0, atk_lev - 1) > def_lev) 2669 if (rndm (0, atk_lev - 1) > def_lev)
2673 { 2670 {
2674 /* make this sucker peaceful. */ 2671 /* make this sucker peaceful. */
2675 2672
2676 change_exp (get_owner (op), victim->stats.exp, op->skill, 0); 2673 change_exp (op->owner, victim->stats.exp, op->skill, 0);
2677 victim->stats.exp = 0; 2674 victim->stats.exp = 0;
2678#if 0 2675#if 0
2679 /* No idea why these were all set to zero - if something 2676 /* No idea why these were all set to zero - if something
2680 * makes this creature agressive, he should still do damage. 2677 * makes this creature agressive, he should still do damage.
2681 */ 2678 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines