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.16 by root, Tue Dec 12 20:53:03 2006 UTC vs.
Revision 1.26 by root, Tue Dec 26 08:55:00 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 wand->remove ();
80 wand->destroy (0); 79 wand->destroy ();
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;
105 wand->stats.food += ncharges; 104 wand->stats.food += ncharges;
106 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s glows with power.", query_name (wand)); 105 new_draw_info_format (NDI_UNIQUE, 0, op, "The %s glows with power.", query_name (wand));
107 if (wand->arch && QUERY_FLAG (&wand->arch->clone, FLAG_ANIMATE)) 106 if (wand->arch && QUERY_FLAG (&wand->arch->clone, FLAG_ANIMATE))
108 { 107 {
109 SET_FLAG (wand, FLAG_ANIMATE); 108 SET_FLAG (wand, FLAG_ANIMATE);
110 wand->speed = wand->arch->clone.speed; 109 wand->set_speed (wand->arch->clone.speed);
111 update_ob_speed (wand);
112 } 110 }
111
113 return 1; 112 return 1;
114} 113}
115 114
116/* Create a missile (nonmagic - magic +4). Will either create bolts or arrows 115/* Create a missile (nonmagic - magic +4). Will either create bolts or arrows
117 * based on whether a crossbow or bow is equiped. If neither, it defaults to 116 * based on whether a crossbow or bow is equiped. If neither, it defaults to
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 missile->destroy (0); 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 missile->destroy (0); 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 wor->remove ();
472 wor->destroy (0); 470 wor->destroy ();
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.
504 502
505 /* value of speed really doesn't make much difference, as long as it is 503 /* value of speed really doesn't make much difference, as long as it is
506 * positive. Lower value may be useful so that the problem doesn't 504 * positive. Lower value may be useful so that the problem doesn't
507 * do anything really odd if it say a -1000 or something. 505 * do anything really odd if it say a -1000 or something.
508 */ 506 */
509 dummy->speed = 0.002; 507 dummy->set_speed (0.002);
510 update_ob_speed (dummy);
511 dummy->speed_left = -dummy->speed * time; 508 dummy->speed_left = -dummy->speed * time;
512 dummy->type = SPELL_EFFECT; 509 dummy->type = SPELL_EFFECT;
513 dummy->subtype = SP_WORD_OF_RECALL; 510 dummy->subtype = SP_WORD_OF_RECALL;
514 511
515 /* If we could take advantage of enter_player_savebed() here, it would be 512 /* If we could take advantage of enter_player_savebed() here, it would be
557 } 554 }
558 return cast_spell (op, caster, dir, newspell, NULL); 555 return cast_spell (op, caster, dir, newspell, NULL);
559 } 556 }
560 return 1; 557 return 1;
561} 558}
562
563 559
564int 560int
565perceive_self (object *op) 561perceive_self (object *op)
566{ 562{
567 char *cp = describe_item (op, op), buf[MAX_BUF]; 563 char *cp = describe_item (op, op), buf[MAX_BUF];
643 char portal_name[1024], portal_message[1024]; 639 char portal_name[1024], portal_message[1024];
644 sint16 exitx, exity; 640 sint16 exitx, exity;
645 maptile *exitmap; 641 maptile *exitmap;
646 int op_level; 642 int op_level;
647 643
648
649 /* Check to see if the map the player is currently on is a per player unique 644 /* 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 645 * map. This can be determined in that per player unique maps have the
651 * full pathname listed. 646 * full pathname listed.
652 */ 647 */
653 if (!strncmp (op->map->path, settings.localdir, strlen (settings.localdir)) && settings.create_home_portals != TRUE) 648 if (!strncmp (op->map->path, settings.localdir, strlen (settings.localdir)) && settings.create_home_portals != TRUE)
661 */ 656 */
662 dummy = arch_to_object (spell->other_arch); 657 dummy = arch_to_object (spell->other_arch);
663 if (dummy == NULL) 658 if (dummy == NULL)
664 { 659 {
665 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 660 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); 661 LOG (llevError, "object::create failed (force in cast_create_town_portal for %s!\n", &op->name);
667 return 0; 662 return 0;
668 } 663 }
664
669 force = check_inv_recursive (op, dummy); 665 force = check_inv_recursive (op, dummy);
670 666
671 if (force == NULL) 667 if (force == NULL)
672 { 668 {
673 /* Here we know there is no destination marked up. 669 /* Here we know there is no destination marked up.
680 EXIT_Y (dummy) = op->y; 676 EXIT_Y (dummy) = op->y;
681 insert_ob_in_ob (dummy, op); 677 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."); 678 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; 679 return 1;
684 } 680 }
681
685 dummy->destroy (0); 682 dummy->destroy ();
686 683
687 /* Here we know where the town portal should go to 684 /* Here we know where the town portal should go to
688 * We should kill any existing portal associated with the player. 685 * We should kill any existing portal associated with the player.
689 * Than we should create the 2 portals. 686 * Than we should create the 2 portals.
690 * For each of them, we need: 687 * For each of them, we need:
703 /* First step: killing existing town portals */ 700 /* First step: killing existing town portals */
704 dummy = get_archetype (spell->race); 701 dummy = get_archetype (spell->race);
705 if (dummy == NULL) 702 if (dummy == NULL)
706 { 703 {
707 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 704 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); 705 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
709 return 0; 706 return 0;
710 } 707 }
708
711 perm_portal = archetype::find (spell->slaying); 709 perm_portal = archetype::find (spell->slaying);
712 710
713 /* To kill a town portal, we go trough the player's inventory, 711 /* To kill a town portal, we go trough the player's inventory,
714 * for each marked portal in player's inventory, 712 * for each marked portal in player's inventory,
715 * -We try load the associated map (if impossible, consider the portal destructed) 713 * -We try load the associated map (if impossible, consider the portal destructed)
733 tmp = present_arch (perm_portal, exitmap, exitx, exity); 731 tmp = present_arch (perm_portal, exitmap, exitx, exity);
734 while (tmp) 732 while (tmp)
735 { 733 {
736 if (tmp->name == old_force->name) 734 if (tmp->name == old_force->name)
737 { 735 {
738 tmp->remove ();
739 tmp->destroy (0); 736 tmp->destroy ();
740 break; 737 break;
741 } 738 }
742 else 739
743 {
744 tmp = tmp->above; 740 tmp = tmp->above;
745 }
746 } 741 }
747 } 742 }
748 old_force->remove (); 743
749 old_force->destroy (0); 744 old_force->destroy ();
750 LOG (llevDebug, "\n"); 745 LOG (llevDebug, "\n");
751 } 746 }
747
752 dummy->destroy (0); 748 dummy->destroy ();
753 749
754 /* Creating the portals. 750 /* Creating the portals.
755 * The very first thing to do is to ensure 751 * The very first thing to do is to ensure
756 * access to the destination map. 752 * access to the destination map.
757 * If we can't, don't fizzle. Simply warn player. 753 * If we can't, don't fizzle. Simply warn player.
769 765
770 /* If we were unable to load (ex. random map deleted), warn player */ 766 /* If we were unable to load (ex. random map deleted), warn player */
771 if (exitmap == NULL) 767 if (exitmap == NULL)
772 { 768 {
773 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?"); 769 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "Something strange happens.\nYou can't remember where to go!?");
774 force->remove ();
775 force->destroy (0); 770 force->destroy ();
776 return 1; 771 return 1;
777 } 772 }
778 773
779 op_level = caster_level (caster, spell); 774 op_level = caster_level (caster, spell);
780 if (op_level < 15) 775 if (op_level < 15)
798 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name); 793 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, &force->name);
799 dummy = get_archetype (spell->slaying); /*The portal */ 794 dummy = get_archetype (spell->slaying); /*The portal */
800 if (dummy == NULL) 795 if (dummy == NULL)
801 { 796 {
802 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 797 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); 798 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
804 return 0; 799 return 0;
805 } 800 }
801
806 EXIT_PATH (dummy) = force->name; 802 EXIT_PATH (dummy) = force->name;
807 EXIT_X (dummy) = EXIT_X (force); 803 EXIT_X (dummy) = EXIT_X (force);
808 EXIT_Y (dummy) = EXIT_Y (force); 804 EXIT_Y (dummy) = EXIT_Y (force);
809 dummy->name = dummy->name_pl = portal_name; 805 dummy->name = dummy->name_pl = portal_name;
810 dummy->msg = portal_message; 806 dummy->msg = portal_message;
817 */ 813 */
818 tmp = get_archetype (spell->race); 814 tmp = get_archetype (spell->race);
819 if (tmp == NULL) 815 if (tmp == NULL)
820 { 816 {
821 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 817 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); 818 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
823 return 0; 819 return 0;
824 } 820 }
821
825 tmp->race = op->map->path; 822 tmp->race = op->map->path;
826 tmp->name = portal_name; 823 tmp->name = portal_name;
827 EXIT_X (tmp) = dummy->x; 824 EXIT_X (tmp) = dummy->x;
828 EXIT_Y (tmp) = dummy->y; 825 EXIT_Y (tmp) = dummy->y;
829 insert_ob_in_ob (tmp, op); 826 insert_ob_in_ob (tmp, op);
837 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path); 834 snprintf (portal_name, 1024, "%s's portal to %s", &op->name, op->map->path);
838 dummy = get_archetype (spell->slaying); /*The portal */ 835 dummy = get_archetype (spell->slaying); /*The portal */
839 if (dummy == NULL) 836 if (dummy == NULL)
840 { 837 {
841 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 838 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); 839 LOG (llevError, "object::create failed (perm_magic_portal) in cast_create_town_portal for %s!\n", &op->name);
843 return 0; 840 return 0;
844 } 841 }
842
845 EXIT_PATH (dummy) = op->map->path; 843 EXIT_PATH (dummy) = op->map->path;
846 EXIT_X (dummy) = op->x; 844 EXIT_X (dummy) = op->x;
847 EXIT_Y (dummy) = op->y; 845 EXIT_Y (dummy) = op->y;
848 dummy->name = dummy->name_pl = portal_name; 846 dummy->name = dummy->name_pl = portal_name;
849 dummy->msg = portal_message; 847 dummy->msg = portal_message;
857 */ 855 */
858 tmp = get_archetype (spell->race); 856 tmp = get_archetype (spell->race);
859 if (tmp == NULL) 857 if (tmp == NULL)
860 { 858 {
861 new_draw_info (NDI_UNIQUE, 0, op, "Oops, program error!"); 859 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); 860 LOG (llevError, "object::create failed (force) in cast_create_town_portal for %s!\n", &op->name);
863 return 0; 861 return 0;
864 } 862 }
863
865 tmp->race = force->name; 864 tmp->race = force->name;
866 tmp->name = portal_name; 865 tmp->name = portal_name;
867 EXIT_X (tmp) = dummy->x; 866 EXIT_X (tmp) = dummy->x;
868 EXIT_Y (tmp) = dummy->y; 867 EXIT_Y (tmp) = dummy->y;
869 insert_ob_in_ob (tmp, op); 868 insert_ob_in_ob (tmp, op);
870 869
871 /* Describe the player what happened 870 /* Describe the player what happened
872 */ 871 */
873 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home."); 872 new_draw_info (NDI_UNIQUE | NDI_NAVY, 0, op, "You see air moving and showing you the way home.");
874 force->remove (); /* Delete the force inside the player */
875 force->destroy (0); 873 force->destroy ();
874
876 return 1; 875 return 1;
877} 876}
878
879 877
880/* This creates magic walls. Really, it can create most any object, 878/* This creates magic walls. Really, it can create most any object,
881 * within some reason. 879 * within some reason.
882 */ 880 */
883
884int 881int
885magic_wall (object *op, object *caster, int dir, object *spell_ob) 882magic_wall (object *op, object *caster, int dir, object *spell_ob)
886{ 883{
887 object *tmp, *tmp2; 884 object *tmp, *tmp2;
888 int i, posblocked, negblocked, maxrange; 885 int i, posblocked, negblocked, maxrange;
900 else 897 else
901 { 898 {
902 x = op->x + freearr_x[dir]; 899 x = op->x + freearr_x[dir];
903 y = op->y + freearr_y[dir]; 900 y = op->y + freearr_y[dir];
904 } 901 }
902
905 m = op->map; 903 m = op->map;
906 904
907 if ((spell_ob->move_block || x != op->x || y != op->y) && 905 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) || 906 (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))) 907 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) == spell_ob->move_block)))
910 { 908 {
911 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way."); 909 new_draw_info (NDI_UNIQUE, 0, op, "Something is in the way.");
912 return 0; 910 return 0;
913 } 911 }
912
914 if (spell_ob->other_arch) 913 if (spell_ob->other_arch)
915 {
916 tmp = arch_to_object (spell_ob->other_arch); 914 tmp = arch_to_object (spell_ob->other_arch);
917 }
918 else if (spell_ob->race) 915 else if (spell_ob->race)
919 { 916 {
920 char buf1[MAX_BUF]; 917 char buf1[MAX_BUF];
921 918
922 sprintf (buf1, spell_ob->race, dir); 919 sprintf (buf1, spell_ob->race, dir);
944 } 941 }
945 else if (QUERY_FLAG (tmp, FLAG_ALIVE)) 942 else if (QUERY_FLAG (tmp, FLAG_ALIVE))
946 { 943 {
947 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 944 tmp->stats.hp = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
948 tmp->stats.maxhp = tmp->stats.hp; 945 tmp->stats.maxhp = tmp->stats.hp;
949 set_owner (tmp, op);
950 set_spell_skill (op, caster, spell_ob, tmp);
951 } 946 }
947
952 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP)) 948 if (QUERY_FLAG (spell_ob, FLAG_IS_USED_UP) || QUERY_FLAG (tmp, FLAG_IS_USED_UP))
953 { 949 {
954 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob); 950 tmp->stats.food = spell_ob->duration + SP_level_duration_adjust (caster, spell_ob);
955 SET_FLAG (tmp, FLAG_IS_USED_UP); 951 SET_FLAG (tmp, FLAG_IS_USED_UP);
956 } 952 }
953
957 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN)) 954 if (QUERY_FLAG (spell_ob, FLAG_TEAR_DOWN))
958 { 955 {
959 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob); 956 tmp->stats.hp = spell_ob->stats.dam + SP_level_dam_adjust (caster, spell_ob);
960 tmp->stats.maxhp = tmp->stats.hp; 957 tmp->stats.maxhp = tmp->stats.hp;
961 SET_FLAG (tmp, FLAG_TEAR_DOWN); 958 SET_FLAG (tmp, FLAG_TEAR_DOWN);
962 SET_FLAG (tmp, FLAG_ALIVE); 959 SET_FLAG (tmp, FLAG_ALIVE);
963 } 960 }
964 961
965 /* This can't really hurt - if the object doesn't kill anything, 962 /* This can't really hurt - if the object doesn't kill anything,
966 * these fields just won't be used. 963 * these fields just won't be used. Do not set the owner for
964 * earthwalls, though, so they survive restarts.
967 */ 965 */
968 set_owner (tmp, op); 966 if (tmp->type != EARTHWALL) //TODO
967 tmp->set_owner (op);
968
969 set_spell_skill (op, caster, spell_ob, tmp); 969 set_spell_skill (op, caster, spell_ob, tmp);
970 tmp->x = x; 970 tmp->x = x;
971 tmp->y = y; 971 tmp->y = y;
972 tmp->level = caster_level (caster, spell_ob) / 2; 972 tmp->level = caster_level (caster, spell_ob) / 2;
973 973
975 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL) 975 if ((tmp = insert_ob_in_map (tmp, m, op, 0)) == NULL)
976 { 976 {
977 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name); 977 new_draw_info_format (NDI_UNIQUE, 0, op, "Something destroys your %s", name);
978 return 0; 978 return 0;
979 } 979 }
980
980 /* If this is a spellcasting wall, need to insert the spell object */ 981 /* If this is a spellcasting wall, need to insert the spell object */
981 if (tmp->other_arch && tmp->other_arch->clone.type == SPELL) 982 if (tmp->other_arch && tmp->other_arch->clone.type == SPELL)
982 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp); 983 insert_ob_in_ob (arch_to_object (tmp->other_arch), tmp);
983 984
984 /* This code causes the wall to extend some distance in 985 /* This code causes the wall to extend some distance in
1002 m = tmp->map; 1003 m = tmp->map;
1003 1004
1004 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 1005 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) 1006 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !posblocked)
1006 { 1007 {
1007 tmp2 = get_object (); 1008 tmp2 = tmp->clone ();
1008 copy_object (tmp, tmp2);
1009 tmp2->x = x; 1009 tmp2->x = x;
1010 tmp2->y = y; 1010 tmp2->y = y;
1011 insert_ob_in_map (tmp2, m, op, 0); 1011 insert_ob_in_map (tmp2, m, op, 0);
1012 /* If this is a spellcasting wall, need to insert the spell object */ 1012 /* If this is a spellcasting wall, need to insert the spell object */
1013 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) 1013 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
1022 m = tmp->map; 1022 m = tmp->map;
1023 1023
1024 if (!(get_map_flags (m, &m, x, y, &x, &y) & (P_OUT_OF_MAP | P_IS_ALIVE)) && 1024 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) 1025 ((spell_ob->move_block & GET_MAP_MOVE_BLOCK (m, x, y)) != spell_ob->move_block) && !negblocked)
1026 { 1026 {
1027 tmp2 = get_object (); 1027 tmp2 = tmp->clone ();
1028 copy_object (tmp, tmp2);
1029 tmp2->x = x; 1028 tmp2->x = x;
1030 tmp2->y = y; 1029 tmp2->y = y;
1031 insert_ob_in_map (tmp2, m, op, 0); 1030 insert_ob_in_map (tmp2, m, op, 0);
1032 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL) 1031 if (tmp2->other_arch && tmp2->other_arch->clone.type == SPELL)
1033 insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2); 1032 insert_ob_in_ob (arch_to_object (tmp2->other_arch), tmp2);
1432 force->stats.ac = spell_ob->stats.ac; 1431 force->stats.ac = spell_ob->stats.ac;
1433 force->attacktype = spell_ob->attacktype; 1432 force->attacktype = spell_ob->attacktype;
1434 1433
1435 insert_ob_in_ob (force, tmp); 1434 insert_ob_in_ob (force, tmp);
1436 change_abil (tmp, force); /* Mostly to display any messages */ 1435 change_abil (tmp, force); /* Mostly to display any messages */
1437 fix_player (tmp); 1436 tmp->update_stats ();
1438 return 1; 1437 return 1;
1439} 1438}
1440 1439
1441/* This used to be part of cast_change_ability, but it really didn't make 1440/* 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 1441 * a lot of sense, since most of the values it derives are from the god
1541 force->stats.wc = spell_ob->stats.wc; 1540 force->stats.wc = spell_ob->stats.wc;
1542 force->stats.ac = spell_ob->stats.ac; 1541 force->stats.ac = spell_ob->stats.ac;
1543 1542
1544 change_abil (tmp, force); /* Mostly to display any messages */ 1543 change_abil (tmp, force); /* Mostly to display any messages */
1545 insert_ob_in_ob (force, tmp); 1544 insert_ob_in_ob (force, tmp);
1546 fix_player (tmp); 1545 tmp->update_stats ();
1547 return 1; 1546 return 1;
1548} 1547}
1549 1548
1550 1549
1551 1550
1621 *small_nuggets -= large->value / small->value; 1620 *small_nuggets -= large->value / small->value;
1622 if (*small_nuggets && large->value % small->value) 1621 if (*small_nuggets && large->value % small->value)
1623 (*small_nuggets)--; 1622 (*small_nuggets)--;
1624 } 1623 }
1625 weight += obj->weight; 1624 weight += obj->weight;
1626 obj->remove ();
1627 obj->destroy (0); 1625 obj->destroy ();
1628} 1626}
1629 1627
1630static void 1628static void
1631update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y) 1629update_map (object *op, maptile *m, int small_nuggets, int large_nuggets, int x, int y)
1632{ 1630{
1639 if (x == op->x && y == op->y && op->map == m) 1637 if (x == op->x && y == op->y && op->map == m)
1640 flag = INS_BELOW_ORIGINATOR; 1638 flag = INS_BELOW_ORIGINATOR;
1641 1639
1642 if (small_nuggets) 1640 if (small_nuggets)
1643 { 1641 {
1644 tmp = get_object (); 1642 tmp = small->clone ();
1645 copy_object (small, tmp);
1646 tmp->nrof = small_nuggets; 1643 tmp->nrof = small_nuggets;
1647 tmp->x = x; 1644 tmp->x = x;
1648 tmp->y = y; 1645 tmp->y = y;
1649 insert_ob_in_map (tmp, m, op, flag); 1646 insert_ob_in_map (tmp, m, op, flag);
1650 } 1647 }
1648
1651 if (large_nuggets) 1649 if (large_nuggets)
1652 { 1650 {
1653 tmp = get_object (); 1651 tmp = large->clone ();
1654 copy_object (large, tmp);
1655 tmp->nrof = large_nuggets; 1652 tmp->nrof = large_nuggets;
1656 tmp->x = x; 1653 tmp->x = x;
1657 tmp->y = y; 1654 tmp->y = y;
1658 insert_ob_in_map (tmp, m, op, flag); 1655 insert_ob_in_map (tmp, m, op, flag);
1659 } 1656 }
1700 continue; 1697 continue;
1701 1698
1702 small_nuggets = 0; 1699 small_nuggets = 0;
1703 large_nuggets = 0; 1700 large_nuggets = 0;
1704 1701
1705 for (tmp = get_map_ob (mp, nx, ny); tmp != NULL; tmp = next) 1702 for (tmp = GET_MAP_OB (mp, nx, ny); tmp != NULL; tmp = next)
1706 { 1703 {
1707 next = tmp->above; 1704 next = tmp->above;
1708 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) && 1705 if (tmp->weight > 0 && !QUERY_FLAG (tmp, FLAG_NO_PICK) &&
1709 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON)) 1706 !QUERY_FLAG (tmp, FLAG_ALIVE) && !QUERY_FLAG (tmp, FLAG_IS_CAULDRON))
1710 { 1707 {
1724 alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight); 1721 alchemy_object (tmp, &small_nuggets, &large_nuggets, &weight);
1725 1722
1726 if (weight > weight_max) 1723 if (weight > weight_max)
1727 { 1724 {
1728 update_map (op, mp, small_nuggets, large_nuggets, nx, ny); 1725 update_map (op, mp, small_nuggets, large_nuggets, nx, ny);
1729 large->destroy (0); 1726 large->destroy ();
1730 small->destroy (0); 1727 small->destroy ();
1731 return 1; 1728 return 1;
1732 } 1729 }
1733 } /* is alchemable object */ 1730 } /* is alchemable object */
1734 } /* process all objects on this space */ 1731 } /* process all objects on this space */
1735 1732
1738 * with this spell. 1735 * with this spell.
1739 */ 1736 */
1740 update_map (op, mp, small_nuggets, large_nuggets, nx, ny); 1737 update_map (op, mp, small_nuggets, large_nuggets, nx, ny);
1741 } 1738 }
1742 } 1739 }
1740
1743 large->destroy (0); 1741 large->destroy ();
1744 small->destroy (0); 1742 small->destroy ();
1745 /* reset this so that if player standing on a big pile of stuff, 1743 /* reset this so that if player standing on a big pile of stuff,
1746 * it is redrawn properly. 1744 * it is redrawn properly.
1747 */ 1745 */
1748 op->contr->socket.look_position = 0; 1746 op->contr->ns->look_position = 0;
1749 return 1; 1747 return 1;
1750} 1748}
1751 1749
1752 1750
1753/* This function removes the cursed/damned status on equipped 1751/* This function removes the cursed/damned status on equipped
1762 for (tmp = op->inv; tmp; tmp = tmp->below) 1760 for (tmp = op->inv; tmp; tmp = tmp->below)
1763 if (QUERY_FLAG (tmp, FLAG_APPLIED) && 1761 if (QUERY_FLAG (tmp, FLAG_APPLIED) &&
1764 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) || 1762 ((QUERY_FLAG (tmp, FLAG_CURSED) && QUERY_FLAG (spell, FLAG_CURSED)) ||
1765 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED)))) 1763 (QUERY_FLAG (tmp, FLAG_DAMNED) && QUERY_FLAG (spell, FLAG_DAMNED))))
1766 { 1764 {
1767
1768 was_one++; 1765 was_one++;
1769 if (tmp->level <= caster_level (caster, spell)) 1766 if (tmp->level <= caster_level (caster, spell))
1770 { 1767 {
1771 success++; 1768 success++;
1772 if (QUERY_FLAG (spell, FLAG_DAMNED)) 1769 if (QUERY_FLAG (spell, FLAG_DAMNED))
1792 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse."); 1789 new_draw_info (NDI_UNIQUE, 0, op, "You failed to remove the curse.");
1793 else 1790 else
1794 new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items."); 1791 new_draw_info (NDI_UNIQUE, 0, op, "You are not using any cursed items.");
1795 } 1792 }
1796 } 1793 }
1794
1797 return success; 1795 return success;
1798} 1796}
1799 1797
1800/* Identifies objects in the players inventory/on the ground */ 1798/* Identifies objects in the players inventory/on the ground */
1801 1799
1808 num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell); 1806 num_ident = spell->stats.dam + SP_level_dam_adjust (caster, spell);
1809 1807
1810 if (num_ident < 1) 1808 if (num_ident < 1)
1811 num_ident = 1; 1809 num_ident = 1;
1812 1810
1813
1814 for (tmp = op->inv; tmp; tmp = tmp->below) 1811 for (tmp = op->inv; tmp; tmp = tmp->below)
1815 { 1812 {
1816 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp)) 1813 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1817 { 1814 {
1818 identify (tmp); 1815 identify (tmp);
1816
1819 if (op->type == PLAYER) 1817 if (op->type == PLAYER)
1820 { 1818 {
1821 new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op)); 1819 new_draw_info_format (NDI_UNIQUE, 0, op, "You have %s.", long_desc (tmp, op));
1820
1822 if (tmp->msg) 1821 if (tmp->msg)
1823 { 1822 {
1824 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); 1823 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1825 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 1824 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1826 } 1825 }
1827 } 1826 }
1827
1828 num_ident--; 1828 num_ident--;
1829 success = 1; 1829 success = 1;
1830 if (!num_ident) 1830 if (!num_ident)
1831 break; 1831 break;
1832 } 1832 }
1833 } 1833 }
1834
1834 /* If all the power of the spell has been used up, don't go and identify 1835 /* 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 1836 * stuff on the floor. Only identify stuff on the floor if the spell
1836 * was not fully used. 1837 * was not fully used.
1837 */ 1838 */
1838 if (num_ident) 1839 if (num_ident)
1839 { 1840 {
1840 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 1841 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)) 1842 if (!QUERY_FLAG (tmp, FLAG_IDENTIFIED) && !tmp->invisible && need_identify (tmp))
1842 { 1843 {
1843
1844 identify (tmp); 1844 identify (tmp);
1845
1845 if (op->type == PLAYER) 1846 if (op->type == PLAYER)
1846 { 1847 {
1847 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op)); 1848 new_draw_info_format (NDI_UNIQUE, 0, op, "On the ground is %s.", long_desc (tmp, op));
1849
1848 if (tmp->msg) 1850 if (tmp->msg)
1849 { 1851 {
1850 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:"); 1852 new_draw_info (NDI_UNIQUE, 0, op, "The item has a story:");
1851 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg); 1853 new_draw_info (NDI_UNIQUE, 0, op, tmp->msg);
1852 } 1854 }
1855
1853 esrv_send_item (op, tmp); 1856 esrv_send_item (op, tmp);
1854 } 1857 }
1858
1855 num_ident--; 1859 num_ident--;
1856 success = 1; 1860 success = 1;
1857 if (!num_ident) 1861 if (!num_ident)
1858 break; 1862 break;
1859 } 1863 }
1860 } 1864 }
1865
1861 if (!success) 1866 if (!success)
1862 new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified."); 1867 new_draw_info (NDI_UNIQUE, 0, op, "You can't reach anything unidentified.");
1863 else 1868 else
1864 {
1865 spell_effect (spell, op->x, op->y, op->map, op); 1869 spell_effect (spell, op->x, op->y, op->map, op);
1866 } 1870
1867 return success; 1871 return success;
1868} 1872}
1869
1870 1873
1871int 1874int
1872cast_detection (object *op, object *caster, object *spell, object *skill) 1875cast_detection (object *op, object *caster, object *spell, object *skill)
1873{ 1876{
1874 object *tmp, *last, *god, *detect; 1877 object *tmp, *last, *god, *detect;
1887 skill = caster; 1890 skill = caster;
1888 1891
1889 for (x = op->x - range; x <= op->x + range; x++) 1892 for (x = op->x - range; x <= op->x + range; x++)
1890 for (y = op->y - range; y <= op->y + range; y++) 1893 for (y = op->y - range; y <= op->y + range; y++)
1891 { 1894 {
1892
1893 m = op->map; 1895 m = op->map;
1894 mflags = get_map_flags (m, &m, x, y, &nx, &ny); 1896 mflags = get_map_flags (m, &m, x, y, &nx, &ny);
1895 if (mflags & P_OUT_OF_MAP) 1897 if (mflags & P_OUT_OF_MAP)
1896 continue; 1898 continue;
1897 1899
1899 * floor. But this is not true for show invisible. 1901 * floor. But this is not true for show invisible.
1900 * Basically, we just go and find the top object and work 1902 * Basically, we just go and find the top object and work
1901 * down - that is easier than working up. 1903 * down - that is easier than working up.
1902 */ 1904 */
1903 1905
1904 for (last = NULL, tmp = get_map_ob (m, nx, ny); tmp; tmp = tmp->above) 1906 for (last = NULL, tmp = GET_MAP_OB (m, nx, ny); tmp; tmp = tmp->above)
1905 last = tmp; 1907 last = tmp;
1908
1906 /* Shouldn't happen, but if there are no objects on a space, this 1909 /* Shouldn't happen, but if there are no objects on a space, this
1907 * would happen. 1910 * would happen.
1908 */ 1911 */
1909 if (!last) 1912 if (!last)
1910 continue; 1913 continue;
1912 done_one = 0; 1915 done_one = 0;
1913 floor = 0; 1916 floor = 0;
1914 detect = NULL; 1917 detect = NULL;
1915 for (tmp = last; tmp; tmp = tmp->below) 1918 for (tmp = last; tmp; tmp = tmp->below)
1916 { 1919 {
1917
1918 /* show invisible */ 1920 /* show invisible */
1919 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) && 1921 if (QUERY_FLAG (spell, FLAG_MAKE_INVIS) &&
1920 /* Might there be other objects that we can make visibile? */ 1922 /* Might there be other objects that we can make visible? */
1921 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) || 1923 (tmp->invisible && (QUERY_FLAG (tmp, FLAG_MONSTER) ||
1922 (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) || 1924 (tmp->type == PLAYER && !QUERY_FLAG (tmp, FLAG_WIZ)) ||
1923 tmp->type == CF_HANDLE || 1925 tmp->type == CF_HANDLE ||
1924 tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE || 1926 tmp->type == TRAPDOOR || tmp->type == EXIT || tmp->type == HOLE ||
1925 tmp->type == BUTTON || tmp->type == TELEPORTER || 1927 tmp->type == BUTTON || tmp->type == TELEPORTER ||
1932 { 1934 {
1933 tmp->invisible = 0; 1935 tmp->invisible = 0;
1934 done_one = 1; 1936 done_one = 1;
1935 } 1937 }
1936 } 1938 }
1939
1937 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR)) 1940 if (QUERY_FLAG (tmp, FLAG_IS_FLOOR))
1938 floor = 1; 1941 floor = 1;
1939 1942
1940 /* All detections below this point don't descend beneath the floor, 1943 /* 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 1944 * so just continue on. We could be clever and look at the type of
2111 2114
2112 mflags = get_map_flags (m, &m, x, y, &x, &y); 2115 mflags = get_map_flags (m, &m, x, y, &x, &y);
2113 2116
2114 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE) 2117 if (!(mflags & P_OUT_OF_MAP) && mflags & P_IS_ALIVE)
2115 { 2118 {
2116 for (plyr = get_map_ob (m, x, y); plyr != NULL; plyr = plyr->above) 2119 for (plyr = GET_MAP_OB (m, x, y); plyr != NULL; plyr = plyr->above)
2117 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE)) 2120 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE))
2118 break; 2121 break;
2119 } 2122 }
2120 2123
2121 2124
2122 /* If we did not find a player in the specified direction, transfer 2125 /* 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. 2126 * to anyone on top of us. This is used for the rune of transference mostly.
2124 */ 2127 */
2125 if (plyr == NULL) 2128 if (plyr == NULL)
2126 for (plyr = get_map_ob (op->map, op->x, op->y); plyr != NULL; plyr = plyr->above) 2129 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)) 2130 if (plyr != op && QUERY_FLAG (plyr, FLAG_ALIVE))
2128 break; 2131 break;
2129 2132
2130 if (!plyr) 2133 if (!plyr)
2131 { 2134 {
2186 m = op->map; 2189 m = op->map;
2187 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy); 2190 mflags = get_map_flags (m, &m, sx, sy, &sx, &sy);
2188 if (mflags & P_OUT_OF_MAP) 2191 if (mflags & P_OUT_OF_MAP)
2189 return; 2192 return;
2190 2193
2191 for (tmp = get_map_ob (m, sx, sy); tmp != NULL; tmp = next) 2194 for (tmp = GET_MAP_OB (m, sx, sy); tmp != NULL; tmp = next)
2192 { 2195 {
2193 next = tmp->above; 2196 next = tmp->above;
2194 2197
2195 /* Need to look at the head object - otherwise, if tmp 2198 /* Need to look at the head object - otherwise, if tmp
2196 * points to a monster, we don't have all the necessary 2199 * points to a monster, we don't have all the necessary
2210 * monsters either. 2213 * monsters either.
2211 */ 2214 */
2212 2215
2213 if (head->attacktype & AT_MAGIC && 2216 if (head->attacktype & AT_MAGIC &&
2214 !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level)) 2217 !(head->attacktype & AT_COUNTERSPELL) && !QUERY_FLAG (head, FLAG_MONSTER) && (op->level > head->level))
2215 {
2216 head->remove ();
2217 head->destroy (0); 2218 head->destroy ();
2218 }
2219 else 2219 else
2220 switch (head->type) 2220 switch (head->type)
2221 { 2221 {
2222 case SPELL_EFFECT: 2222 case SPELL_EFFECT:
2223 if (op->level > head->level) 2223 if (op->level > head->level)
2224 {
2225 head->remove ();
2226 head->destroy (0); 2224 head->destroy ();
2227 } 2225
2228 break; 2226 break;
2229 2227
2230 /* I really don't get this rune code that much - that 2228 /* I really don't get this rune code that much - that
2231 * random chance seems really low. 2229 * random chance seems really low.
2232 */ 2230 */
2233 case RUNE: 2231 case RUNE:
2234 if (rndm (0, 149) == 0) 2232 if (rndm (0, 149) == 0)
2235 { 2233 {
2236 head->stats.hp--; /* weaken the rune */ 2234 head->stats.hp--; /* weaken the rune */
2237 if (!head->stats.hp) 2235 if (!head->stats.hp)
2238 {
2239 head->remove ();
2240 head->destroy (0); 2236 head->destroy ();
2241 }
2242 } 2237 }
2243 break; 2238 break;
2244 } 2239 }
2245 } 2240 }
2246} 2241}
2383 CLEAR_FLAG (tmp, FLAG_MONSTER); 2378 CLEAR_FLAG (tmp, FLAG_MONSTER);
2384 SET_FLAG (tmp, FLAG_FRIENDLY); 2379 SET_FLAG (tmp, FLAG_FRIENDLY);
2385 tmp->stats.exp = 0; 2380 tmp->stats.exp = 0;
2386 add_friendly_object (tmp); 2381 add_friendly_object (tmp);
2387 tmp->type = GOLEM; 2382 tmp->type = GOLEM;
2388 set_owner (tmp, op); 2383 tmp->set_owner (op);
2389 set_spell_skill (op, caster, spell, tmp); 2384 set_spell_skill (op, caster, spell, tmp);
2390 op->contr->ranges[range_golem] = tmp; 2385 op->contr->ranges[range_golem] = tmp;
2391 op->contr->shoottype = range_golem; 2386 op->contr->shoottype = range_golem;
2392 2387
2393 /* Give the weapon to the golem now. A bit of a hack to check the 2388 /* Give the weapon to the golem now. A bit of a hack to check the
2402 * so instead, just set it as equipped (otherwise, we need to update 2397 * so instead, just set it as equipped (otherwise, we need to update
2403 * body_info, skills, etc) 2398 * body_info, skills, etc)
2404 */ 2399 */
2405 SET_FLAG (tmp, FLAG_USE_WEAPON); 2400 SET_FLAG (tmp, FLAG_USE_WEAPON);
2406 SET_FLAG (weapon, FLAG_APPLIED); 2401 SET_FLAG (weapon, FLAG_APPLIED);
2407 fix_player (tmp); 2402 tmp->update_stats ();
2408 2403
2409 /* There used to be 'odd' code that basically seemed to take the absolute 2404 /* 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 - 2405 * 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. 2406 * if you're using a crappy weapon, it shouldn't be as good.
2412 */ 2407 */
2464 if (a > 14) 2459 if (a > 14)
2465 a = 14; 2460 a = 14;
2466 tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a)); 2461 tmp->resist[ATNR_PHYSICAL] = 100 - (int) ((100.0 - (float) tmp->resist[ATNR_PHYSICAL]) / (30.0 - 2.0 * a));
2467 2462
2468 /* Determine golem's speed */ 2463 /* Determine golem's speed */
2469 tmp->speed = 0.4 + 0.1 * SP_level_range_adjust (caster, spell); 2464 tmp->set_speed (min (3.33, 0.4 + 0.1 * SP_level_range_adjust (caster, spell)));
2470
2471 if (tmp->speed > 3.33)
2472 tmp->speed = 3.33;
2473 2465
2474 if (!spell->race) 2466 if (!spell->race)
2475 { 2467 {
2476 sprintf (buf, "animated %s", &weapon->name); 2468 sprintf (buf, "animated %s", &weapon->name);
2477 tmp->name = buf; 2469 tmp->name = buf;
2479 tmp->face = weapon->face; 2471 tmp->face = weapon->face;
2480 tmp->animation_id = weapon->animation_id; 2472 tmp->animation_id = weapon->animation_id;
2481 tmp->anim_speed = weapon->anim_speed; 2473 tmp->anim_speed = weapon->anim_speed;
2482 tmp->last_anim = weapon->last_anim; 2474 tmp->last_anim = weapon->last_anim;
2483 tmp->state = weapon->state; 2475 tmp->state = weapon->state;
2484 if (QUERY_FLAG (weapon, FLAG_ANIMATE)) 2476 tmp->flag [FLAG_ANIMATE] = weapon->flag [FLAG_ANIMATE];
2485 {
2486 SET_FLAG (tmp, FLAG_ANIMATE);
2487 }
2488 else
2489 {
2490 CLEAR_FLAG (tmp, FLAG_ANIMATE);
2491 }
2492 update_ob_speed (tmp);
2493 } 2477 }
2494 2478
2495 /* make experience increase in proportion to the strength of the summoned creature. */ 2479 /* make experience increase in proportion to the strength of the summoned creature. */
2496 tmp->stats.exp *= 1 + (MAX (spell->stats.maxgrace, spell->stats.sp) / caster_level (caster, spell)); 2480 tmp->stats.exp *= 1 + (MAX (spell->stats.maxgrace, spell->stats.sp) / caster_level (caster, spell));
2497 2481
2550 2534
2551 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell); 2535 new_aura->duration = spell->duration + 10 * SP_level_duration_adjust (caster, spell);
2552 2536
2553 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell); 2537 new_aura->stats.dam = spell->stats.dam + SP_level_dam_adjust (caster, spell);
2554 2538
2555 set_owner (new_aura, op); 2539 new_aura->set_owner (op);
2556 set_spell_skill (op, caster, spell, new_aura); 2540 set_spell_skill (op, caster, spell, new_aura);
2557 new_aura->attacktype = spell->attacktype; 2541 new_aura->attacktype = spell->attacktype;
2558 2542
2559 new_aura->level = caster_level (caster, spell); 2543 new_aura->level = caster_level (caster, spell);
2560 if (refresh) 2544 if (refresh)
2591 aura->remove (); 2575 aura->remove ();
2592 2576
2593 /* exit if we're out of gas */ 2577 /* exit if we're out of gas */
2594 if (aura->duration-- < 0) 2578 if (aura->duration-- < 0)
2595 { 2579 {
2596 aura->destroy (0); 2580 aura->destroy ();
2597 return; 2581 return;
2598 } 2582 }
2599 2583
2600 /* auras only exist in inventories */ 2584 /* auras only exist in inventories */
2601 if (env == NULL || env->map == NULL) 2585 if (env == NULL || env->map == NULL)
2602 { 2586 {
2603 aura->destroy (0); 2587 aura->destroy ();
2604 return; 2588 return;
2605 } 2589 }
2590
2606 aura->x = env->x; 2591 aura->x = env->x;
2607 aura->y = env->y; 2592 aura->y = env->y;
2608 2593
2609 /* we need to jump out of the inventory for a bit 2594 /* we need to jump out of the inventory for a bit
2610 * in order to hit the map conveniently. 2595 * in order to hit the map conveniently.
2650void 2635void
2651move_peacemaker (object *op) 2636move_peacemaker (object *op)
2652{ 2637{
2653 object *tmp; 2638 object *tmp;
2654 2639
2655 for (tmp = get_map_ob (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above) 2640 for (tmp = GET_MAP_OB (op->map, op->x, op->y); tmp != NULL; tmp = tmp->above)
2656 { 2641 {
2657 int atk_lev, def_lev; 2642 int atk_lev, def_lev;
2658 object *victim = tmp; 2643 object *victim = tmp;
2659 2644
2660 if (tmp->head) 2645 if (tmp->head)
2671 2656
2672 if (rndm (0, atk_lev - 1) > def_lev) 2657 if (rndm (0, atk_lev - 1) > def_lev)
2673 { 2658 {
2674 /* make this sucker peaceful. */ 2659 /* make this sucker peaceful. */
2675 2660
2676 change_exp (get_owner (op), victim->stats.exp, op->skill, 0); 2661 change_exp (op->owner, victim->stats.exp, op->skill, 0);
2677 victim->stats.exp = 0; 2662 victim->stats.exp = 0;
2678#if 0 2663#if 0
2679 /* No idea why these were all set to zero - if something 2664 /* No idea why these were all set to zero - if something
2680 * makes this creature agressive, he should still do damage. 2665 * makes this creature agressive, he should still do damage.
2681 */ 2666 */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines